Files
lilishop-ui/manager/vue.config.js
pikachu1995@126.com 615ee91511 manager 升级到vue3
2026-05-25 10:49:09 +08:00

77 lines
1.8 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 = {
css: {
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true,
},
},
scss: {
sassOptions: {
silenceDeprecations: ["legacy-js-api", "import"],
},
},
sass: {
sassOptions: {
silenceDeprecations: ["legacy-js-api", "import"],
},
},
},
},
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: /[\\/]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;
});
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [path.resolve(__dirname, "./src/styles/common.scss")],
},
},
};