vue.config.js基本配置
const BundleAnalyzerPlugin = require(“webpack-bundle-analyzer”)
.BundleAnalyzerPlugin;
const CompressionWebpackPlugin = require(“compression-webpack-plugin”);
const BASE_URL = process.env.BASE_URL || “/”;
const path = require(“path”);
module.exports = {
lintOnSave: false,
publicPath: BASE_URL,
assetsDir: “assets”,
transpileDependencies: [“vuetify”],
productionSourceMap: false,
devServer: {
port: 5222,
open: process.platform === “darwin”,
host: “0.0.0.0”,
https: false
},
configureWebpack: {
name: “e-road”,
plugins:
process.env.NODE_ENV === “development”
? [
//压缩文件
new CompressionWebpackPlugin({
test: /.jsKaTeX parse error: Can't use function '\.' in math mode at position 2: |\̲.̲html|.\css/, //匹配文件名
threshold: 10240, //对超过10k的数据压缩
deleteOriginalAssets: false //不删除源文件
})
]
: [
//dist大小分析
new BundleAnalyzerPlugin(),
new CompressionWebpackPlugin({
test: /.jsKaTeX parse error: Can't use function '\.' in math mode at position 2: |\̲.̲html|.\css/, //匹配文件名
threshold: 10240, //对超过10k的数据压缩
deleteOriginalAssets: false //不删除源文件
})
],
externals: {
moment: “moment”,
vue: “Vue”,
vuetify: “Vuetify”
},
context: path.resolve(__dirname, “./”),
//别名配置
resolve: {
extensions: [",js", “.vue”],
alias: {
“@”: path.resolve(“src”)
}
}
}
};