-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
50 lines (49 loc) · 1.15 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
41
42
43
44
45
46
47
48
49
50
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import Pages from 'vite-plugin-pages'
import * as path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{ find: /^~/, replacement: '' }, // 解决 vite 不支持 less 文件以 ~ 开头引入的问题
{ find: '@', replacement: path.resolve(__dirname, 'src') }
]
},
plugins: [
react(),
Pages({
dirs: 'src/views',
moduleId: '@@react-pages' // 因 less ~ 引入方式解决影响路由系统的默认文件 ~react-pages,故更改别名
})
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
},
server: {
host: '127.0.0.1',
port: 4000,
strictPort: false,
proxy: {
'/api/': {
target: 'http://127.0.0.1:8888',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
},
cors: true
},
build: {
sourcemap: false,
rollupOptions: {
// production build rollup options
plugins: []
}
},
envDir: path.resolve(__dirname, 'env'),
envPrefix: 'WOOC_'
})