🔧(react) rollup type files

Previously types file were splitted into their original folder
tree structure. By enabling this option we could just get one
global .d.ts file. To make this more handy I created a dedicated
build bash file, the package.json was starting to get messy.
This commit is contained in:
Nathan Vasse
2023-05-04 15:07:04 +02:00
committed by NathanVss
parent d4a574c30f
commit 7513b4d217
4 changed files with 26 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": minor
---
fix type files imports and rollup them

7
packages/react/build Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
tsc
yarn build-theme
vite build
yarn build-fonts
yarn build-icons
cp -R src/locales dist/

View File

@@ -28,7 +28,7 @@
"scripts": { "scripts": {
"lint": "eslint . 'src/**/*.{ts,tsx}'", "lint": "eslint . 'src/**/*.{ts,tsx}'",
"dev": "yarn storybook & nodemon --watch src --ext '*' --ignore src/cunningham-tokens.ts --ignore src/cunningham-tokens.js --ignore src/cunningham-tokens.css --exec npm run build", "dev": "yarn storybook & nodemon --watch src --ext '*' --ignore src/cunningham-tokens.ts --ignore src/cunningham-tokens.js --ignore src/cunningham-tokens.css --exec npm run build",
"build": "tsc && yarn build-theme && vite build && yarn build-fonts && yarn build-icons", "build": "./build",
"build-fonts": "vite build -c vite.fonts.config.ts && rm -rf dist/fonts.js && mkdir -p dist/sass && cp src/fonts.scss dist/sass/", "build-fonts": "vite build -c vite.fonts.config.ts && rm -rf dist/fonts.js && mkdir -p dist/sass && cp src/fonts.scss dist/sass/",
"build-icons": "vite build -c vite.icons.config.ts && rm -rf dist/icons.js && mkdir -p dist/sass && cp src/icons.scss dist/sass/", "build-icons": "vite build -c vite.icons.config.ts && rm -rf dist/icons.js && mkdir -p dist/sass && cp src/icons.scss dist/sass/",
"build-theme": "cunningham -o src -g css,ts,js", "build-theme": "cunningham -o src -g css,ts,js",

View File

@@ -26,7 +26,19 @@ export default defineConfig({
}, },
}, },
}, },
plugins: [tsconfigPaths(), dts(), react()], plugins: [
tsconfigPaths(),
dts({
rollupTypes: true,
beforeWriteFile: (filePath, content) => {
return {
filePath,
content: content.replace("../../locales", "./locales"),
};
},
}),
react(),
],
test: { test: {
environment: "jsdom", environment: "jsdom",
reporters: "verbose", reporters: "verbose",