|
|
@ -2,7 +2,7 @@ |
|
|
|
* Author: Fu Guobin |
|
|
|
* Date: 2022/12/28 |
|
|
|
* Last Modified by: Fu Guobin |
|
|
|
* Last Modified time: 2023/08/28 |
|
|
|
* Last Modified time: 2023/09/15 |
|
|
|
* Copyright:Daniel(Fu Guobin) |
|
|
|
* Description:vite配置 |
|
|
|
*/ |
|
|
@ -11,8 +11,8 @@ import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite'; |
|
|
|
import AutoImport from 'unplugin-auto-import/vite'; |
|
|
|
import Components from 'unplugin-vue-components/vite'; |
|
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; |
|
|
|
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers' |
|
|
|
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; |
|
|
|
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'; |
|
|
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; |
|
|
|
import Icons from 'unplugin-icons/vite'; |
|
|
|
import IconsResolver from 'unplugin-icons/resolver'; |
|
|
|
import path from 'path'; |
|
|
@ -28,29 +28,28 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { |
|
|
|
} |
|
|
|
}, |
|
|
|
//静态资源处理
|
|
|
|
assetsInclude: "", |
|
|
|
assetsInclude: '', |
|
|
|
//控制台输出的级别 info 、warn、error、silent
|
|
|
|
logLevel: "info", |
|
|
|
logLevel: 'info', |
|
|
|
// 设为false 可以避免 vite 清屏而错过在终端中打印某些关键信息
|
|
|
|
clearScreen: true, |
|
|
|
//本地运行配置,以及反向代理配置
|
|
|
|
server: { |
|
|
|
host: "localhost", |
|
|
|
https: false,//是否启用 http 2
|
|
|
|
cors: true,//为开发服务器配置 CORS , 默认启用并允许任何源
|
|
|
|
open: true,//服务启动时自动在浏览器中打开应用
|
|
|
|
host: 'localhost', |
|
|
|
https: false, //是否启用 http 2
|
|
|
|
cors: true, //为开发服务器配置 CORS , 默认启用并允许任何源
|
|
|
|
open: true, //服务启动时自动在浏览器中打开应用
|
|
|
|
port: Number(env.VITE_APP_PORT), |
|
|
|
strictPort: false, //设为true时端口被占用则直接退出,不会尝试下一个可用端口
|
|
|
|
force: false,//是否强制依赖预构建
|
|
|
|
hmr: true,//配置HMR
|
|
|
|
force: false, //是否强制依赖预构建
|
|
|
|
hmr: true, //配置HMR
|
|
|
|
proxy: { |
|
|
|
[env.VITE_APP_BASE_API]: { |
|
|
|
// target: 'http://172.1.2.106:9000/',//本地接口地址
|
|
|
|
// target: 'http://172.1.2.48:9000/',//本地接口地址
|
|
|
|
target: 'http://board.heatiot.cn:8001/prod-api/',//线上接口地址
|
|
|
|
target: 'http://board.heatiot.cn:8001/prod-api/', //线上接口地址
|
|
|
|
changeOrigin: true, |
|
|
|
rewrite: path => |
|
|
|
path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') |
|
|
|
rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
@ -95,10 +94,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { |
|
|
|
|
|
|
|
createSvgIconsPlugin({ |
|
|
|
// 指定需要缓存的图标文件夹
|
|
|
|
iconDirs: [path.resolve(pathSrc, "assets/icons")], |
|
|
|
iconDirs: [path.resolve(pathSrc, 'assets/icons')], |
|
|
|
// 指定symbolId格式
|
|
|
|
symbolId: "icon-[dir]-[name]", |
|
|
|
}), |
|
|
|
symbolId: 'icon-[dir]-[name]' |
|
|
|
}) |
|
|
|
], |
|
|
|
css: { |
|
|
|
// CSS 预处理器
|
|
|
@ -112,14 +111,18 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// esbuild: {
|
|
|
|
// //打包时去除console和debugger代码
|
|
|
|
// drop: ['console', 'debugger']
|
|
|
|
// },
|
|
|
|
//打包配置
|
|
|
|
build: { |
|
|
|
//浏览器兼容性 "esnext"|"modules"
|
|
|
|
target: "modules", |
|
|
|
target: 'modules', |
|
|
|
//指定输出路径
|
|
|
|
outDir: "dist", |
|
|
|
outDir: 'dist', |
|
|
|
//生成静态资源的存放路径
|
|
|
|
assetsDir: "assets", |
|
|
|
assetsDir: 'assets', |
|
|
|
//小于此阈值的导入或引用资源将内联为 base64 编码,以避免额外的 http 请求。设置为 0 可以完全禁用此项
|
|
|
|
assetsInlineLimit: 4096, |
|
|
|
//启用/禁用 CSS 代码拆分
|
|
|
@ -127,19 +130,22 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { |
|
|
|
//构建后是否生成 source map 文件
|
|
|
|
sourcemap: false, |
|
|
|
//自定义底层的 Rollup 打包配置
|
|
|
|
rollupOptions: { |
|
|
|
}, |
|
|
|
rollupOptions: {}, |
|
|
|
//@rollup/plugin-commonjs 插件的选项
|
|
|
|
commonjsOptions: { |
|
|
|
}, |
|
|
|
commonjsOptions: {}, |
|
|
|
//当设置为 true,构建后将会生成 manifest.json 文件
|
|
|
|
manifest: false, |
|
|
|
// 设置为 false 可以禁用最小化混淆,
|
|
|
|
// 或是用来指定使用哪种混淆器
|
|
|
|
// boolean | 'terser' | 'esbuild'
|
|
|
|
minify: "terser", //terser 构建后文件体积更小
|
|
|
|
minify: 'terser', //terser 构建后文件体积更小
|
|
|
|
//传递给 Terser 的更多 minify 选项。
|
|
|
|
terserOptions: { |
|
|
|
compress: { |
|
|
|
//生产环境时移除console
|
|
|
|
drop_console: true, |
|
|
|
drop_debugger: true |
|
|
|
} |
|
|
|
}, |
|
|
|
//设置为 false 来禁用将构建后的文件写入磁盘
|
|
|
|
write: true, |
|
|
@ -191,7 +197,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { |
|
|
|
'element-plus/es/components/pagination/style/css', |
|
|
|
'element-plus/es/components/tree/style/css', |
|
|
|
'element-plus/es/components/alert/style/css', |
|
|
|
|
|
|
|
|
|
|
|
'@vueuse/core', |
|
|
|
'path-to-regexp', |
|
|
|
'echarts', |
|
|
|