mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-08 01:48:56 +08:00
- 清理:删除 4 个未使用依赖、约 2700 行死代码(shop/ossManage 等)、tree-table 死组件、37 处未使用 import - ESLint 9 flat config 升级(.eslintrc.js -> eslint.config.js),修复迁移遗留的 34 处真实 bug - axios 重构:拦截器不再吞错、refreshToken 单例共享 Promise、超时收敛、form 序列化抽公共函数、vue-router 4 失效 API 修正 - 安全:4 处 v-html 增加 xss 过滤;logout 改为精确删除 localStorage 键 - API 重复定义收敛(delSpec/insertOrUpdateSpec、getDictData、ws) - 首屏瘦身:tinymce 懒加载(约省 7.4MB)、core-js 按需 polyfill、vendor chunk 合并、dplayer/@antv/g2 动态 import、3 张大图压缩 - 页面修复:发布商品表单布局(iview 遗留 margin 移除)、beforeVideoUpload 补定义、el-tag type 空值、lili-dialog emits 声明、消息中心布局塌陷修复与样式重构、department-choose 空值、affix-time 不再发多余店铺请求、goods/distributionGoods 去掉品牌筛选
108 lines
3.1 KiB
JavaScript
108 lines
3.1 KiB
JavaScript
const path = require("path");
|
||
const configs = require("./src/config");
|
||
const CompressionPlugin = require("compression-webpack-plugin");
|
||
|
||
const resolve = (dir) => path.join(__dirname, dir);
|
||
|
||
const enableProduction = process.env.NODE_ENV === "production";
|
||
|
||
module.exports = {
|
||
publicPath: process.env.VUE_APP_PUBLIC_PATH || "/",
|
||
outputDir: "dist",
|
||
assetsDir: "static",
|
||
css: {
|
||
sourceMap: false,
|
||
loaderOptions: {
|
||
less: {
|
||
lessOptions: {
|
||
javascriptEnabled: true,
|
||
},
|
||
},
|
||
scss: {
|
||
sassOptions: {
|
||
silenceDeprecations: ["legacy-js-api", "import"],
|
||
},
|
||
},
|
||
sass: {
|
||
sassOptions: {
|
||
silenceDeprecations: ["legacy-js-api", "import"],
|
||
},
|
||
},
|
||
},
|
||
},
|
||
devServer: {
|
||
port: configs.port,
|
||
client: {
|
||
overlay: {
|
||
runtimeErrors: (error) => {
|
||
const message = error?.message || "";
|
||
if (message.includes("ResizeObserver loop")) {
|
||
return false;
|
||
}
|
||
// 接口请求失败已由 axios 拦截器统一弹 toast,不再触发错误弹层
|
||
if (error?.name === "AxiosError" || message.startsWith("Request failed with status code")) {
|
||
return false;
|
||
}
|
||
// 腾讯地图 GL 在跨域脚本里抛错时,浏览器只上报 Script error.
|
||
if (message === "Script error." || message.includes("far <= 0") || message.includes("near <= 0")) {
|
||
return false;
|
||
}
|
||
return true;
|
||
},
|
||
},
|
||
},
|
||
},
|
||
productionSourceMap: false,
|
||
configureWebpack: {
|
||
plugins: enableProduction
|
||
? [
|
||
new CompressionPlugin({
|
||
test: /\.js$|\.html$|\.css/,
|
||
threshold: 10240,
|
||
}),
|
||
]
|
||
: [],
|
||
optimization: {
|
||
runtimeChunk: "single",
|
||
splitChunks: {
|
||
chunks: "all",
|
||
minSize: 30000,
|
||
cacheGroups: {
|
||
// 框架核心单独成 chunk:长期缓存,不随业务代码变化而失效
|
||
framework: {
|
||
test: /[\\/]node_modules[\\/](vue|vue-router|vuex|axios|element-plus|@element-plus|@vue|@vueuse|core-js)[\\/]/,
|
||
name: "chunk-framework",
|
||
priority: 30,
|
||
enforce: true,
|
||
},
|
||
// 首屏直接依赖的其余第三方包合并为一个 chunk,避免上百个小请求
|
||
vendor: {
|
||
test: /[\\/]node_modules[\\/]/,
|
||
name: "chunk-vendor",
|
||
chunks: "initial",
|
||
priority: 20,
|
||
},
|
||
},
|
||
},
|
||
},
|
||
},
|
||
chainWebpack(config) {
|
||
config.resolve.alias
|
||
.set("@", resolve("src"))
|
||
.set("@/components/lili", resolve("src/views/my-components/lili"))
|
||
.set("@/components/map", resolve("src/views/my-components/map"))
|
||
.set("@/components/lili-dialog", resolve("src/views/lili-dialog"))
|
||
.set("@/components/hotzone", resolve("src/views/shop/hotzone"));
|
||
config.plugin("html").tap((args) => {
|
||
args[0].cdn = { css: [], js: [] };
|
||
return args;
|
||
});
|
||
},
|
||
pluginOptions: {
|
||
"style-resources-loader": {
|
||
preProcessor: "scss",
|
||
patterns: [path.resolve(__dirname, "./src/styles/common.scss")],
|
||
},
|
||
},
|
||
};
|