-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
40 lines (37 loc) · 1.19 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import react from '@vitejs/plugin-react';
import md5 from 'md5';
import { defineConfig } from 'vite';
import eslint from 'vite-plugin-eslint';
import stylelint from 'vite-plugin-stylelint';
const regex = /(.*node_modules\/)([^\/]+)(.*)/;
const linter = process.env.VITE_ENV === 'prod' ? [] : [eslint(), stylelint()];
export default defineConfig({
plugins: [react(), ...linter],
css: {
devSourcemap: process.env.VITE_SOURCE_MAP === 'true',
},
build: {
sourcemap: process.env.VITE_SOURCE_MAP === 'true',
rollupOptions: {
output: {
manualChunks: (id, meta) => {
if (id.includes('node_modules') && meta.getModuleInfo(id).isIncluded) {
const hash = md5(regex.exec(id)[2].replace('@', ''));
return `vendor/${hash.slice(0, 8)}`;
}
},
},
},
minify: 'terser',
terserOptions: {
sourceMap: process.env.VITE_SOURCE_MAP === 'true',
ecma: 2018,
compress: {
ecma: 2018,
},
format: {
ecma: 2018,
},
},
},
});