Files
qualifications-management-vue/vue.config.js
8324144 cddb096a72 init
2026-05-18 14:57:00 +08:00

81 lines
3.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 在vue-config.js 中加入
const Timestamp = new Date().getTime();
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = ['js', 'css'];
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
publicPath: process.env.NODE_ENV === "production" ? "./" : "./", // 部署应用时的根路径(默认'/'),也可用相对路径(存在使用限制)
outputDir: process.env.outputDir, //process.env.outputDir 运行时生成的生产环境构建文件的目录(默认''dist'',构建之前会被清除)
assetsDir: "static", //放置生成的静态资源(s、css、img、fonts)的(相对于 outputDir 的)目录(默认'')
lintOnSave: false, // 是否开启eslint保存检测
productionSourceMap: false, // 是否在构建生产包时生成sourcdeMap
devServer: {
/* 本地ip地址 */
host: "0.0.0.0",
port: "8020",
hot: true,
/* 自动打开浏览器 */
open: false,
overlay: {
warning: false,
error: true
}, // 错误、警告在页面弹出
/* 跨域代理 */
proxy: {
"/api": {
/* 目标代理服务器地址 */
// target: process.env.VUE_APP_API,
target: 'http://127.0.0.1:8089',
/* 允许跨域 */
changeOrigin: true,
ws: true,
pathRewrite: {
"^/api": ""
}
}
}
},
configureWebpack: config => {
if (isProduction) {
config.plugins.push(new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
}))
}
config["externals"] = {
// 'vue': 'Vue',
// 'vue-router': 'VueRouter',
// 'vuex': 'Vuex',
// 'axios': 'axios'
}
config["performance"] = {
hints: 'warning',
// 入口起点的最大体积 整数类型(以字节为单位)
maxEntrypointSize: 50000000,
// 生成文件的最大体积 整数类型(以字节为单位 300k
maxAssetSize: 30000000,
// 只给出 js 文件的性能提示
assetFilter: function (assetFilename) {
return assetFilename.endsWith('.js')
}
},
// 输出重构
config.output.filename = `js/[name].${Timestamp}.js`
config.output.chunkFilename = `js/[name].${Timestamp}.js`
},
css: {
extract: {
filename: `css/[name].${Timestamp}.css`,
chunkFilename: `css/[name].${Timestamp}.css`
}
},
chainWebpack: config => {
// 移除prefetch插件
config.plugins.delete("prefetch");
config.plugins.delete('preload');
}
}