forked from acm309/PutongOJ-FE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
110 lines (109 loc) · 2.97 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { defineConfig } from 'vite';
import path from 'path';
import { createVuePlugin } from 'vite-plugin-vue2';
import envCompatible from 'vite-plugin-env-compatible';
import { injectHtml } from 'vite-plugin-html';
import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
import { visualizer } from 'rollup-plugin-visualizer';
// import createImportPlugin from 'vite-plugin-import'
import viteCompression from 'vite-plugin-compression';
import legacy from '@vitejs/plugin-legacy'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{
find: /^~/,
replacement: ''
},
{
find: '@',
replacement: path.resolve(__dirname, 'src')
}
],
extensions: [
'.mjs',
'.js',
'.ts',
'.jsx',
'.tsx',
'.json',
'.vue'
]
},
plugins: [
createVuePlugin({ jsx: false }),
viteCommonjs(),
// support browsers which don't support esm
legacy(),
envCompatible(),
injectHtml(),
visualizer({
// generate stats.html in project root
// sourcemap: true,
// brotliSize: true,
gzipSize: true
}),
viteCompression()
// 会报错:require is not defined
// createImportPlugin([
// {
// libraryName: 'iview',
// libraryDirectory: 'src/components'
// }
// ]),
],
// optimizeDeps: {
// esbuildOptions: {
// plugins: [
// esbuildCommonjs(['iview'])
// ]
// }
// },
build: {
target: 'es2017',
reportCompressedSize: false,
// sourcemap: true,
// https://next.router.vuejs.org/guide/advanced/lazy-loading.html#with-vite
rollupOptions: {
output: {
manualChunks: {
'common': ['vue', 'vuex', 'vue-router', 'axios'],
'ui': ['iview']
}
// 不知道为啥,这两个都变成了 modulepreload,一开始就加载了
// 预想是访问里特定网页才加载
// manualChunks: {
// 'statistics': [
// './src/views/Problem/Statistics'
// ],
// 'admin': [
// './src/views/Problem/ProblemEdit',
// './src/views/Problem/Testcase',
// './src/views/Contest/ContestEdit',
// './src/views/News/NewsEdit',
// './src/views/Admin/ProblemCreate',
// './src/views/Admin/ContestCreate',
// './src/views/Admin/NewsCreate',
// './src/views/Admin/UserManage/Usermanage',
// './src/views/Admin/UserManage/UserEdit',
// './src/views/Admin/UserManage/GroupEdit',
// './src/views/Admin/UserManage/AdminEdit',
// './src/views/Admin/UserManage/TagEdit',
// ]
// },
}
}
},
server: {
port: 3000,
proxy: {
'/api': {
target: process.env.RATS_BE_ADDRESS,
//target: 'http://code.mju-rats.com-be:8888',
//target: 'http://localhost:8888',
changeOrigin: true
}
}
}
})