Files
lilishop-ui/manager/vue.config.js
pikachu1995@126.com 8484936e3d refactor(axios): 优化HTTP请求拦截器和错误处理机制
- 移除调试用的console.log语句
- 调整表格列对齐方式,将操作列从居中改为右对齐
- 添加搜索表单功能,包括账单号、店铺名称、生成时间等筛选条件
- 重构axios拦截器逻辑,简化错误处理流程
- 实现统一的token刷新机制,使用单例模式避免重复请求
- 优化防抖函数实现,提高性能表现
- 添加401和403状态码的特殊处理逻辑
- 统一错误提示信息的显示方式
- 优化表格列宽度设置,调整金额相关列的显示效果
- 删除未使用的组件文件和样式代码
- 移除调试相关的代码和注释
- 优化图标组件的导入方式,使用markRaw包装
- 优化热词统计图表的数据显示逻辑,添加空数据提示
2026-10-08 14:39:12 +08:00

107 lines
2.9 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 || "/",
css: {
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?.isAxiosError ||
error?.name === "AxiosError" ||
message.includes("Request failed with status code") ||
message.includes("Network Error") ||
message.includes("timeout of")
) {
return false;
}
return true;
},
},
},
},
productionSourceMap: false,
configureWebpack: {
plugins: enableProduction
? [
new CompressionPlugin({
test: /\.js$|\.html$|\.css/,
threshold: 10240,
}),
]
: [],
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "all",
maxInitialRequests: Infinity,
minSize: 20000,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const match = module.context && module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
);
const packageName = match ? match[1] : "vendor";
return `npm.${packageName.replace("@", "")}`;
},
},
},
},
},
},
chainWebpack(config) {
config.resolve.alias.set("@", resolve("src"));
config.plugin("html").tap((args) => {
args[0].cdn = { css: [], js: [] };
return args;
});
if (enableProduction) {
// 生产环境移除所有 console.* 调用
config.optimization.minimizer("terser").tap((args) => {
const terserOptions = args[0].terserOptions || (args[0].terserOptions = {});
terserOptions.compress = { ...terserOptions.compress, drop_console: true };
return args;
});
}
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [path.resolve(__dirname, "./src/styles/variables.scss")],
},
},
};