提交 2cce373a authored 作者: 刘旭's avatar 刘旭

新增字段 租户标识 租户域名

上级 392e301d
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// vite 提供的操作env配置变量的方法loadEnv
import { loadEnv } from 'vite';
import { loadEnv } from "vite";
// nodejs写法,获取项目目录
import path from 'path';
import path from "path";
//按需要加载
// import AutoImport from 'unplugin-auto-import/vite'
......@@ -11,128 +11,135 @@ import path from 'path';
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import Icons from 'unplugin-icons/vite'
// import IconsResolver from 'unplugin-icons/resolver'
import Inspect from 'vite-plugin-inspect'
import { viteMockServe } from 'vite-plugin-mock'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
const pathSrc = path.resolve(__dirname, 'src')
import Inspect from "vite-plugin-inspect";
import { viteMockServe } from "vite-plugin-mock";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
const pathSrc = path.resolve(__dirname, "src");
// https://vitejs.dev/config/
export default ({ command, mode }) => {
const env = loadEnv(mode, process.cwd())
return defineConfig({
plugins: [
vue(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]'
}),
viteMockServe({
// default
mockPath: 'mock',
}),
// AutoImport({
// // Auto import functions from Vue, e.g. ref, reactive, toRef...
// // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
// imports: ['vue'],
const env = loadEnv(mode, process.cwd());
return defineConfig({
plugins: [
vue(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
// 指定symbolId格式
symbolId: "icon-[dir]-[name]",
}),
viteMockServe({
// default
mockPath: "mock",
}),
// AutoImport({
// // Auto import functions from Vue, e.g. ref, reactive, toRef...
// // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
// imports: ['vue'],
// // Auto import functions from Element Plus, e.g. ElMessage, ElMessageBox... (with style)
// // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
// resolvers: [
// ElementPlusResolver(),
// // Auto import functions from Element Plus, e.g. ElMessage, ElMessageBox... (with style)
// // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
// resolvers: [
// ElementPlusResolver(),
// // Auto import icon components
// // 自动导入图标组件
// IconsResolver({
// prefix: 'Icon',
// }),
// ],
// // Auto import icon components
// // 自动导入图标组件
// IconsResolver({
// prefix: 'Icon',
// }),
// ],
// dts: path.resolve(pathSrc, 'auto-imports.d.ts'),
// }),
// dts: path.resolve(pathSrc, 'auto-imports.d.ts'),
// }),
// Components({
// resolvers: [
// // Auto register icon components
// // 自动注册图标组件
// IconsResolver({
// enabledCollections: ['ep'],
// }),
// // Auto register Element Plus components
// // 自动导入 Element Plus 组件
// ElementPlusResolver(),
// ],
// Components({
// resolvers: [
// // Auto register icon components
// // 自动注册图标组件
// IconsResolver({
// enabledCollections: ['ep'],
// }),
// // Auto register Element Plus components
// // 自动导入 Element Plus 组件
// ElementPlusResolver(),
// ],
// dts: path.resolve(pathSrc, 'components.d.ts'),
// }),
// dts: path.resolve(pathSrc, 'components.d.ts'),
// }),
// Icons({
// autoInstall: true,
// }),
// Icons({
// autoInstall: true,
// }),
Inspect(),
],
// 服务器配置
server: {
host: '0.0.0.0',
port: Number(loadEnv(mode, process.cwd()).VITE_APP_PORT),
strictPort: false, // 端口被占用直接退出
https: false, // 默认用http方式
open: true,// 在开发服务器启动时自动在浏览器中打开应用程序
proxy: { // 代理配置
// 字符串简写写法
// '/foo': '',
// 选项写法
"/lic": {
target: 'http://192.168.0.8:8090'
// rewrite: (path) => path.replace(/^\/api/, '')
},
// 正则表达式写法
// '^/fallback/.*': {
// target: 'http://jsonplaceholder.typicode.com',
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/fallback/, '')
// },
},
hmr: {
overlay: true // 屏蔽服务器报错
}
},
resolve: { // 设置项目文件导入路径
alias: {
'@': pathSrc
}
Inspect(),
],
// 服务器配置
server: {
host: "0.0.0.0",
port: Number(loadEnv(mode, process.cwd()).VITE_APP_PORT),
strictPort: false, // 端口被占用直接退出
https: false, // 默认用http方式
open: true, // 在开发服务器启动时自动在浏览器中打开应用程序
proxy: {
// 代理配置
// 字符串简写写法
// '/foo': '',
// 选项写法
"/lic": {
target: "http://192.168.1.27:8090",
// rewrite: (path) => path.replace(/^\/api/, '')
},
css: {
// css预处理器
preprocessorOptions: {
// 引入 var.scss 这样就可以在全局中使用 var.scss中预定义的变量了
// 给导入的路径最后加上 ;
// 正则表达式写法
// '^/fallback/.*': {
// target: 'http://jsonplaceholder.typicode.com',
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/fallback/, '')
// },
},
hmr: {
overlay: true, // 屏蔽服务器报错
},
},
resolve: {
// 设置项目文件导入路径
alias: {
"@": pathSrc,
},
},
css: {
// css预处理器
preprocessorOptions: {
// 引入 var.scss 这样就可以在全局中使用 var.scss中预定义的变量了
// 给导入的路径最后加上 ;
scss: {
charset: false,//防止样式出现警告,中文
additionalData: '@import "@/assets/styles/global.scss";'
}
}
scss: {
charset: false, //防止样式出现警告,中文
additionalData: '@import "@/assets/styles/global.scss";',
},
build: { // 分块打包配置
chunkSizeWarningLimit: 1500, // 分块打包,分解块,将大块分解成更小的块
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
},
terserOptions: {
compress: {
drop_console: true, // 生产环境移除console
drop_debugger: true // 生产环境移除debugger
}
},
},
build: {
// 分块打包配置
chunkSizeWarningLimit: 1500, // 分块打包,分解块,将大块分解成更小的块
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
}
})
}
\ No newline at end of file
},
},
},
terserOptions: {
compress: {
drop_console: true, // 生产环境移除console
drop_debugger: true, // 生产环境移除debugger
},
},
},
});
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论