初版提交
This commit is contained in:
68
vite.config.js
Normal file
68
vite.config.js
Normal file
@ -0,0 +1,68 @@
|
||||
import {
|
||||
resolve
|
||||
} from 'path'
|
||||
import {
|
||||
defineConfig,
|
||||
loadEnv
|
||||
} from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import inject from '@rollup/plugin-inject'
|
||||
import {
|
||||
createHtmlPlugin
|
||||
} from 'vite-plugin-html'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
base: '/',
|
||||
// 服务端渲染
|
||||
server: {
|
||||
// 是否开启 https
|
||||
https: false,
|
||||
// 端口号
|
||||
port: 5173,
|
||||
host: '0.0.0.0',
|
||||
// 本地跨域代理 https://cn.vitejs.dev/config/server-options.html#server-proxy
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8082/', // 测试环境
|
||||
// target: 'http://lingtuoyun.unt.ink:10000/api/', // 线上测试环境
|
||||
// target: 'http://tnserver.natapp1.cc/api/',
|
||||
// target: 'http://lty.x.untrip.cc/api/',//线上环境
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
},
|
||||
// 自定义中间件
|
||||
middleware: [],
|
||||
// 是否开启自动刷新
|
||||
hmr: true,
|
||||
// 是否开启自动打开浏览器
|
||||
open: true,
|
||||
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
inject({
|
||||
$: 'jquery', // 这里会自动载入 node_modules 中的 jquery
|
||||
jQuery: 'jquery',
|
||||
'windows.jQuery': 'jquery',
|
||||
BMap: 'BMap'
|
||||
}),
|
||||
createHtmlPlugin({
|
||||
/**
|
||||
* 需要注入 index.html ejs 模版的数据
|
||||
* https://blog.csdn.net/SilenceJude/article/details/128297371
|
||||
*/
|
||||
inject: {
|
||||
data: {
|
||||
VITE_APP_VERSION: new Date().toLocaleString()
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, './src')
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user