Skip to content

Commit 21c5ad4

Browse files
committed
update config
1 parent e52a7ff commit 21c5ad4

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "eslint --ext .ts,.tsx src --color",
1212
"format": "prettier --write \"./src/**/*.{ts,tsx,json}\"",
1313
"prepare": "husky install",
14-
"analyze": "source-map-explorer 'dist/assets/*.js'"
14+
"analyze": "npm run lint && tsc && vite build --mode=analyze && source-map-explorer 'dist/assets/*.js'"
1515
},
1616
"dependencies": {
1717
"react": "^18.2.0",

vite.config.ts

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,47 @@ import checker from 'vite-plugin-checker';
55
import * as path from 'path';
66

77
// https://vitejs.dev/config/
8-
export default defineConfig({
9-
plugins: [
10-
react(),
11-
EnvironmentPlugin('all'),
12-
// resolve({ "react-codemirror2": `
13-
// const UnControlled = {};
14-
// export {
15-
// UnControlled,
16-
// }`
17-
// }
18-
checker({
19-
typescript: true,
20-
}),
21-
],
22-
optimizeDeps: {
23-
include: ['react'],
24-
},
25-
css: {
26-
devSourcemap: true,
27-
},
28-
build: {
29-
commonjsOptions: {
30-
include: [/node_modules/],
8+
export default defineConfig(({ mode }) => {
9+
const isDev = mode !== 'production';
10+
const isAnalyze = mode === 'analyze';
11+
12+
return {
13+
plugins: [
14+
react(),
15+
EnvironmentPlugin('all'),
16+
// resolve({ "react-codemirror2": `
17+
// const UnControlled = {};
18+
// export {
19+
// UnControlled,
20+
// }`
21+
// }
22+
checker({
23+
typescript: true,
24+
}),
25+
],
26+
optimizeDeps: {
27+
include: ['react'],
28+
},
29+
css: {
30+
devSourcemap: isDev,
31+
},
32+
build: {
33+
commonjsOptions: {
34+
include: [/node_modules/],
35+
},
36+
sourcemap: isAnalyze,
37+
},
38+
resolve: {
39+
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
40+
},
41+
esbuild: {
42+
sourcemap: isDev,
43+
},
44+
server: {
45+
port: 3000,
46+
},
47+
preview: {
48+
port: 3000,
3149
},
32-
// sourcemap: true // Check analyze
33-
},
34-
resolve: {
35-
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
36-
},
37-
esbuild: {
38-
sourcemap: true,
39-
},
40-
server: {
41-
port: 3000,
42-
},
43-
preview: {
44-
port: 3000,
45-
},
50+
};
4651
});

0 commit comments

Comments
 (0)