加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
QIQI 提交于 2024-03-14 17:51 . fix 长订阅不支持
import { ConfigEnv, UserConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import AutoImport from 'unplugin-auto-import/vite';
import eslintPlugin from 'vite-plugin-eslint';
import { resolve } from 'path';
import Unocss from 'unocss/vite';
import { loadEnv } from 'vite';
// https://vitejs.cn/config/
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd();
const env = loadEnv(mode, root);
return {
base: './',
resolve: {
alias: {
'@': resolve('./src'),
'@root': resolve('./'),
},
},
define: {
'process.env': {},
},
build: {
minify: 'terser',
terserOptions: {
compress: {
// 发布时删除 console
// drop_console: true,
},
},
},
server: {
host: true,
proxy: {
'/api': {
target: env.VITE_PROXY_BASE_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/upload': {
target: env.VITE_PROXY_UPLOAD_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/upload/, ''),
},
},
hmr: {
overlay: false,
},
},
plugins: [
uni(),
Unocss(),
AutoImport({
include: [/\.[tj]sx?$/, /\.vue/],
imports: ['vue', 'uni-app'],
dts: 'typings/auto-imports.d.ts',
}),
eslintPlugin({
include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.ts'],
exclude: ['./node_modules/**'],
cache: false,
}),
// vitePluginRequire({
// // @fileRegex RegExp
// // optional:default file processing rules are as follows
// // fileRegex:/(.jsx?|.tsx?|.vue)$/
// // Conversion mode. The default mode is import
// // importMetaUrl | import
// // importMetaUrl see https://vitejs.cn/guide/assets.html#new-url-url-import-meta-url
// // translateType: "importMetaUrl" | "import";
// })
],
css: {
preprocessorOptions: {
scss: {
// additionalData: '@import "@/assets/style/main.scss";',
},
},
},
};
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化