You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
'use strict'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import VueDevTools from 'vite-plugin-vue-devtools'
|
|
import path from 'path'
|
|
|
|
const pathResolve = (dir) => {
|
|
// eslint-disable-next-line no-undef
|
|
return path.resolve(__dirname, dir)
|
|
}
|
|
|
|
export default ({ mode }) => {
|
|
// const env = loadEnv(mode, process.cwd()) // 获取.env文件里定义的环境变量
|
|
// console.log(env); //变量在命令行里打印出来
|
|
return defineConfig({
|
|
plugins: [vue(), VueDevTools()],
|
|
server: {
|
|
host: '127.0.0.1',
|
|
port: 7005,
|
|
hmr: true,
|
|
proxy: {
|
|
// 跨域设置,在后端已经设置
|
|
// '/api': {
|
|
// target: env.VITE_API_BASE_URL,
|
|
// changeOrigin: true,
|
|
// rewrite: (path) => {
|
|
// console.log(path)
|
|
// return path
|
|
// },
|
|
// }
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': pathResolve('src')
|
|
}
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
api: 'modern-compiler', // 或 "modern","legacy"
|
|
importers: [
|
|
// ...
|
|
],
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|