Skip to content

Commit

Permalink
fix(codemods): exportation of vite build for codemods
Browse files Browse the repository at this point in the history
  • Loading branch information
panvourtsis committed May 21, 2024
1 parent 3fcf71d commit 3b41c0c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ server
**/*.test.tsx
__mocks__
./vite.config.ts
./vite.codemods.config.ts
./rollup.config.js
!.storybook
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ build-storybook.log
./bundle-analysis.html

vite.config.ts*
vite.codemods.config.ts*
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-storybook": "^0.6.15",
"express": "^4.19.2",
"fast-glob": "^3.3.2",
"history": "^4.10.1",
"husky": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
Expand Down Expand Up @@ -165,7 +166,9 @@
"prepare": "husky install",
"start": "storybook dev -p 6006",
"prebuild": "rimraf dist",
"build:lib": "yarn prebuild && vite build",
"build:main": "vite build",
"build:codemods": "vite build --config vite.codemods.config.ts",
"build:lib": "yarn prebuild && yarn build:main && yarn build:codemods",
"build": "storybook build -o build/",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"test": "vitest --run",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "vite.codemods.config.ts"]
}
36 changes: 36 additions & 0 deletions vite.codemods.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import path from 'path';
import fg from 'fast-glob';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import tsconfigPaths from 'vite-tsconfig-paths';

const codemodsEntries = Object.fromEntries(
fg
.sync('codemods/**/*.ts')
.map((file) => [
path.relative('codemods', file.slice(0, file.length - path.extname(file).length)),
path.resolve(file),
])
);

export default defineConfig({
plugins: [
tsconfigPaths(),
dts({
outDir: path.resolve(__dirname, 'dist/codemods'),
include: ['codemods/**/*.ts'],
exclude: ['__mocks__'],
}),
],
build: {
rollupOptions: {
input: codemodsEntries,
output: {
dir: path.resolve(__dirname, 'dist/codemods'),
format: 'es',
entryFileNames: '[name].js',
},
external: ['react', 'react-dom', 'emotion-reset', /@emotion\/styled/, /@emotion\/react/],
},
},
});

0 comments on commit 3b41c0c

Please sign in to comment.