-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
73 lines (71 loc) · 2.13 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { defineConfig, loadEnv } from 'vite'
import type { CommonServerOptions } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path from 'path'
// import { viteLogo } from './src/core/config.ts'
// viteLogo(process.env)
console.log(JSON.stringify(import.meta)) // undefined
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
console.log('command', process.env.VITE_HHHH)
const env = loadEnv(mode, process.cwd())
console.log('command', env)
return {
base: './', // index.html文件所在位置
root: './', // js导入的资源路径,src
resolve: {
extensions: ['.ts', '.vue', '.tsx'],
alias: {
'@': path.resolve(__dirname, 'src')
}
},
server: <CommonServerOptions>{
// 如果使用docker-compose开发模式,设置为false
open: false,
port: 8180,
// host: '0.0.0.0', // expose local iP address
proxy: {
'/db': { // 需要代理的路径 例如 '/api'
target: `http://www.cwl.gov.cn`, // 代理到 目标路径
changeOrigin: true,
rewrite: (path) => path.replace(/^\/db/, '')
},
'/lo': { // 需要代理的路径 例如 '/api'
target: `https://webapi.sporttery.cn/`, // 代理到 目标路径
changeOrigin: true,
rewrite: (path) => path.replace(/^\/lo/, '')
},
'/v1': {
target: 'http://localhost:8000',
// rewrite: path => path.replace(//, '')
}
}
},
css: {
preprocessorOptions: {
scss: {
// 支持内联 JavaScript
javascriptEnabled: true
},
// scss: {
// // additionalData: `$injectedColor: orange;`
// additionalData: '$variables ?= @import "./src/styles/variables.scss";',
// // use: ['style-loader', 'css-loader', 'sass-loader']
// }
}
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
plugins: [
vue(),
vueJsx({})
]
}
})