Skip to content

Commit ea0b2df

Browse files
committed
optimize the build
1 parent bdf787d commit ea0b2df

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

vite.config.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import viteTsconfigPaths from 'vite-tsconfig-paths'
88
export default defineConfig(({ mode }) => {
99
const env = loadEnv(mode, process.cwd(), '')
1010
const buildTarget = env.VITE_BUILD_TARGET || 'web'
11+
const buildPlatform = env.VITE_BUILD_PLATFORM
1112

1213
if (!env.VITE_API_URL) {
1314
throw new Error('VITE_API_URL is not defined, create an .env file with this variable')
1415
}
1516

17+
if (buildTarget == 'extension' && !buildPlatform) {
18+
throw new Error('VITE_BUILD_PLATFORM is not defined, create an .env file with this variable')
19+
}
20+
1621
return {
1722
plugins: [
1823
ViteEjsPlugin((viteConfig) => {
@@ -29,14 +34,8 @@ export default defineConfig(({ mode }) => {
2934
},
3035
build: {
3136
emptyOutDir: true,
32-
minify: 'terser',
33-
terserOptions: {
34-
format: {
35-
beautify: true,
36-
},
37-
},
3837
rollupOptions: {
39-
...(buildTarget === 'extension'
38+
...(buildTarget === 'extension' && buildPlatform === 'firefox'
4039
? {
4140
output: {
4241
manualChunks: () => 'main.js',
@@ -45,7 +44,23 @@ export default defineConfig(({ mode }) => {
4544
assetFileNames: `assets/[name].[ext]`,
4645
},
4746
}
48-
: {}),
47+
: {
48+
output: {
49+
manualChunks: {
50+
settings: [
51+
'react-contexify',
52+
'react-modal',
53+
'react-select',
54+
'react-share',
55+
'react-simple-toasts',
56+
'react-spinners',
57+
'react-toggle',
58+
'react-tooltip',
59+
],
60+
react: ['react', 'react-dom', 'react-router-dom', 'react-device-detect'],
61+
},
62+
},
63+
}),
4964
},
5065
},
5166
server: {

0 commit comments

Comments
 (0)