-
Notifications
You must be signed in to change notification settings - Fork 274
/
vite.config.mjs
59 lines (56 loc) · 1.37 KB
/
vite.config.mjs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { defineConfig } from 'vite';
import path from 'path';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import mdx from '@mdx-js/rollup';
import remarkGfm from 'remark-gfm';
export default ({ mode, command }) => {
const buildDoc = mode === 'doc';
const isProd = command === 'build';
return defineConfig({
base: './',
build: {
target: ['chrome100'],
sourcemap: isProd ? 'hidden' : true,
outDir: buildDoc ? 'docs-dist' : 'dist',
rollupOptions: {
onwarn(warning, defaultHandler) {
if (warning.code === 'SOURCEMAP_ERROR') {
return;
}
defaultHandler(warning);
},
output: {
manualChunks: {
react: ['react'],
'react-dom': ['react-dom'],
'react-router-dom': ['react-router-dom'],
},
},
},
},
resolve: {
alias: [{ find: '@', replacement: path.join(__dirname, './src') }],
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
hack: `true; @import "${process.cwd()}/src/assets/style/variable.less";`,
},
},
},
},
plugins: [
{
enforce: 'pre',
...mdx({
remarkPlugins: [remarkGfm],
}),
},
react(),
svgr(),
],
});
};