-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvite.config.js
66 lines (64 loc) · 1.68 KB
/
vite.config.js
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
60
61
62
63
64
65
66
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import vitePluginForArco from '@arco-plugins/vite-react';
import { viteMockServe } from 'vite-plugin-mock';
const path = require('path');
const isDev = process.env.NODE_ENV === 'development';
// https://vitejs.dev/config/
export default defineConfig({
base: '/arco-admin-template',
plugins: [
react(),
vitePluginForArco(),
viteMockServe({
mockPath: 'mock',
localEnabled: isDev,
prodEnabled: !isDev,
supportTs: false,
watchFiles: true,
injectCode: `
import { setupProdMockServer } from './mockProdServer';
setupProdMockServer();
`,
injectFile: path.resolve(process.cwd(), 'src/main.jsx')
})
],
resolve: {
alias: {
'~': path.resolve(__dirname, './'), // 根路径
'@': path.resolve(__dirname, 'src') // src 路径
}
},
server: {
port: 3001,
host: '0.0.0.0',
open: true
// proxy: {
// "/api": {
// target: "https://624659e7e3450d61b0fd6ba2.mockapi.io/api/v1",
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/dev-api/, ""),
// },
// },
},
build: {
terserOptions: {
compress: {
keep_infinity: true,
drop_console: true
}
},
// chunk 大小警告的限制
chunkSizeWarningLimit: 2000,
outDir: 'dist'
},
css: {
preprocessorOptions: {
less: {
additionalData: `@import "${path.resolve(__dirname, 'src/styles/variable.less')}";`,
// 支持内联 JavaScript
javascriptEnabled: true
}
}
}
});