代码拉取完成,页面将自动刷新
import { resolve } from 'path'
import { loadEnv } from 'vite'
import type { ConfigEnv, UserConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import EslintPlugin from 'vite-plugin-eslint'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
// 路径查找
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir)
}
// https://vitejs.cn/config/
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const env = loadEnv(mode, root)
return {
base: env.VITE_BASE_PATH,
root: root,
// 服务端渲染
server: {
// 是否开启 https
https: false,
// 端口号
port: env.VITE_PORT as unknown as number,
host: "0.0.0.0",
open: env.VITE_OPEN,
// 本地跨域代理
proxy: {
['/dev-api']: {
target: env.VITE_BASE_URL,
ws: false,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^/dev-api`), ''),
},
},
},
resolve: {
alias: [
{
find: /\@\//,
replacement: `${pathResolve('src')}/`
}
]
},
define: {
'process.env': {}
},
build: {
minify: 'terser',
terserOptions: {
compress: {
// 发布时删除 console
// drop_console: true,
}
}
},
plugins: [
uni(),
EslintPlugin({
cache: false,
include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.ts'],
exclude: ['./node_modules/**']
}),
VueI18n({
runtimeOnly: true,
compositionOnly: true,
include: [resolve(__dirname, 'src/locales/**')]
})
]
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。