-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
36 lines (33 loc) · 1.04 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
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import { wrapperEnv, createProxy } from './build/utils'
import { createVitePlugins } from './build/plugin'
export default defineConfig(({ command, mode }) => {
const isBuild = command === 'build'
const env = loadEnv(mode, process.cwd())
const viteEnv = wrapperEnv(env)
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY } = viteEnv
return {
plugins: createVitePlugins(viteEnv, isBuild),
base: VITE_PUBLIC_PATH || '/',
resolve: {
// 设置别名
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
css: {
preprocessorOptions: {
//define global scss variable
scss: {
additionalData: `@import '@/styles/variables.scss';`,
},
},
},
server: {
host: '0.0.0.0', // 默认为'127.0.0.1',如果将此设置为 `0.0.0.0` 或者 `true` 将监听所有地址,包括局域网和公网地址
port: VITE_PORT, // 端口
proxy: createProxy(VITE_PROXY), // 代理
},
}
})