mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
- 新增 eslint.config.js(flat config, vue3-essential),移除废弃的 .eslintrc.js/.eslintignore(引用已废弃的 babel-eslint),package.json 增加 lint/lint:fix 脚本 - 清理 17 处调试 console.log;修复 24 处空 catch(15 处补 console.warn 业务提示,9 处加注释说明可安全忽略) - 修复存量 lint error:9 处 prop 默认值改为函数形式、3 处未使用组件、1 处 v-if/v-for 同级、1 处空 else - vue.config.js 生产环境 terser 开启 drop_console 兜底
93 lines
2.5 KiB
JavaScript
93 lines
2.5 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: {
|
|
sass: {
|
|
additionalData: `@import "@/assets/styles/global.scss";`,
|
|
sassOptions: {
|
|
silenceDeprecations: ["legacy-js-api", "import"],
|
|
},
|
|
},
|
|
scss: {
|
|
additionalData: `@import "@/assets/styles/global.scss";`,
|
|
sassOptions: {
|
|
silenceDeprecations: ["legacy-js-api", "import"],
|
|
},
|
|
},
|
|
less: {
|
|
lessOptions: {
|
|
javascriptEnabled: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
devServer: {
|
|
port: configs.port,
|
|
},
|
|
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(module) {
|
|
if (!module.context) return false;
|
|
if (/[\\/]node_modules[\\/]vue-qr[\\/]/.test(module.context)) {
|
|
return false;
|
|
}
|
|
return /[\\/]node_modules[\\/]/.test(module.context);
|
|
},
|
|
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: [] };
|
|
args[0].title = configs.title;
|
|
return args;
|
|
});
|
|
// 生产环境兜底:压缩时移除所有 console 输出
|
|
if (enableProduction) {
|
|
config.optimization.minimizer("terser").tap((args) => {
|
|
args[0].terserOptions.compress = {
|
|
...args[0].terserOptions.compress,
|
|
drop_console: true,
|
|
};
|
|
return args;
|
|
});
|
|
}
|
|
},
|
|
};
|