1 Star 0 Fork 11

szbitway/Peach-Design-Template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 2.24 KB
一键复制 编辑 原始数据 按行查看 历史
秋叶 提交于 2021-05-09 17:13 . --
/**
* webpack 配置(vue-cli提示的vue.config.js)
* @type {{devServer: {port: number, open: boolean}}}
*/
const path = require("path");
const resolve = dir => {
return path.join(__dirname, dir);
};
const isDev = process.env.NODE_ENV === "development";
const CompressionWebpackPlugin = require("compression-webpack-plugin");
const ProductionGzipExtensions = ["html", "js", "css", "svg"];
const WebpackBar = require("webpackbar");
const webpackBarName = "peach-admin";
module.exports = {
publicPath: "",
outputDir: "dist/admin",
// 构建时开启多进程处理babel编译
devServer: {
open: true,
port: 8083,
},
configureWebpack(config) {
//配置根目录
return {
resolve: {
alias: {
"@": resolve("src")
}
},
plugins: [
new WebpackBar({
name: webpackBarName
})
]
};
},
chainWebpack(config) {
config.when(isDev, config => {
config.resolve.symlinks(true);
config.devtool("source-map");
});
config.resolve.symlinks(true);
config.when(!isDev, config => {
config.plugins.delete("prefetch");
config.devtool("none");
//splitChunks拆分
config.optimization.splitChunks({
chunks: "all",
cacheGroups: {
libs: {
name: "Chunk-Libs",
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: "initial"
},
AntdUI: {
name: "Chunk-Antd",
priority: 20,
test: /[\\/]node_modules[\\/]_?@ant-design(.*)/
}
}
});
//Gzip
config
.plugin("compression")
.use(CompressionWebpackPlugin, [
{
filename: "[path][base].gz[query]",
algorithm: "gzip",
test: new RegExp(
"\\.(" + ProductionGzipExtensions.join("|") + ")$"
),
threshold: 8192,
minRatio: 0.8
}
])
.end();
});
},
runtimeCompiler: true,
productionSourceMap: false,
css: {
extract: !isDev,
requireModuleExtension: true,
sourceMap: true,
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true
}
}
}
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/szbitway/peach-design-template.git
git@gitee.com:szbitway/peach-design-template.git
szbitway
peach-design-template
Peach-Design-Template
master

搜索帮助