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

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

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