-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathvite.config.ts
More file actions
51 lines (50 loc) · 1.59 KB
/
Copy pathvite.config.ts
File metadata and controls
51 lines (50 loc) · 1.59 KB
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
import path from 'node:path';
import {defineConfig, loadEnv} from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
const env = loadEnv(mode, process.cwd(), '');
return {
base: env.PUBLIC_PATH || '/',
envPrefix: ['VITE_', 'USER_', 'PUBLIC_', 'ENV'],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
Components: path.resolve(__dirname, 'src/components'),
Utils: path.resolve(__dirname, 'src/utils')
}
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
generateScopedName: '[name]__[local]__[hash:base64:5]'
}
},
plugins: [
react(),
svgr() // 通过 `import Icon from 'xxx.svg?react'` 把 svg 当作 React 组件引入
],
server: {
host: true,
port: 3000,
open: true
},
build: {
outDir: 'build',
sourcemap: false,
rollupOptions: {
output: {
manualChunks(id) {
if (/node_modules\/(react|react-dom|react-router|scheduler)\//.test(id)) {
return 'react';
}
if (/node_modules\/(mobx|mobx-react-lite)\//.test(id)) {
return 'mobx';
}
}
}
}
}
};
});