3 Star 30 Fork 10

xingyu/uniapp-vue3-ts-template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vite.config.ts 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
xingyu 提交于 2023-09-26 12:02 . chore: update deps
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/**')]
})
]
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/xingyuv/uniapp-vue3-ts-template.git
git@gitee.com:xingyuv/uniapp-vue3-ts-template.git
xingyuv
uniapp-vue3-ts-template
uniapp-vue3-ts-template
master

搜索帮助