代码拉取完成,页面将自动刷新
const path = require('path')
const webpack = require('webpack')
const CompressionPlugin = require('compression-webpack-plugin')
const zlib = require('zlib')
const createThemeColorReplacerPlugin = require('./config/plugin.config')
const { log } = require('console')
function resolve (dir) {
return path.join(__dirname, dir)
}
/*
const cdn = {
css: [],
js: [
'https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js',
'https://cdn.jsdelivr.net/npm/vue-router@3.1.3/dist/vue-router.min.js',
'https://cdn.jsdelivr.net/npm/vuex@3.1.1/dist/vuex.min.js',
'https://cdn.jsdelivr.net/npm/axios@0.19.0/dist/axios.min.js'
]
} */
/* const isProd = process.env.NODE_ENV === 'production'
const assetsCDN = {
// webpack build externals
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
axios: 'axios'
},
} */
// vue.config.js
let timeStamp = new Date().getTime(); // 最新版本号时间戳
const vueConfig = {
/* chainWebpack: config => {
config.module
.rule('eslint')
.use('eslint-loader')
.loader('eslint-loader')
.tap(options => {
options.fix = true
return options
})
}, */
configureWebpack: {
// webpack plugins
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
//vue EventBus
// 压缩成 .gz 文件
/* new CompressionPlugin({
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
}),
// 压缩成 .br 文件,如果 zlib 报错无法解决,可以注释这段使用代码,一般本地没问题,需要注意线上服务器会可能发生找不到 zlib 的情况。
new CompressionPlugin({
filename: '[path][base].br',
algorithm: 'brotliCompress',
test: /\.(js|css|html|svg)$/,
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 11
}
},
threshold: 10240,
minRatio: 0.8
}) */
],
output: { // 输出重构 打包编译后的js文件名称,添加时间戳.
filename: `static/js/js[name].${timeStamp}.js`,
chunkFilename: `static/js/chunk.[id].${timeStamp}.js`,
},
// if prod, add externals
externals: {}//isProd ? assetsCDN.externals : {}
},
chainWebpack: (config) => {
config.resolve.alias
.set('@$', resolve('src'))
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-svg-icon-loader')
.loader('vue-svg-icon-loader')
.end()
.end()
.oneOf('external')
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/[name].[hash:8].[ext]'
})
// if prod is on
// assets require on cdn
/* if (isProd) {
config.plugin('html').tap(args => {
args[0].cdn = cdn
return args
})
} */
},
css: {
extract: { // 打包后css文件名称添加时间戳
filename: `static/css/[name].${timeStamp}.css`,
chunkFilename: `static/css/chunk.[id].${timeStamp}.css`,
},
loaderOptions: {
less: {
modifyVars: {
// less vars,customize ant design theme
// 'primary-color': '#F5222D',
// 'link-color': '#F5222D',
// 'border-radius-base': '4px'
},
// DO NOT REMOVE THIS LINE
javascriptEnabled: true
}
}
},
runtimeCompiler: true,//解决自定义模版
publicPath: '/',
outputDir: process.env.VUE_APP_DIST,
assetsDir: 'static',
lintOnSave: false,
productionSourceMap: false,
devServer: {
port: 8081,
// host:'localhost',
open: true, // 项目运行时自动在浏览器打开
hotOnly: false, // 构建失败时回退
headers: {
"Access-Control-Allow-Origin": "*",
},
// https://apifox.com/apidoc/shared-549c4a92-9ae2-45b1-88f4-83c270340f72 接口文档
// https://lanhuapp.com/url/f2oIi 原型
// 本地 http://192.168.0.104:8082 (吴)
// 预测试 http://120.77.240.246:80/apis
// 正式环境 https://admin.taxdata.top || https://employ.taxdata.top
proxy: {
'/apis': {
target: process.env.NODE_ENV === 'development' ? "http://120.77.240.246:80/apis":"",
changeOrigin: true,//是否跨域
pathRewrite: { //匹配路径
"^/apis": ''
}
}
}
}
}
// preview.pro.loacg.com only do not use in your production;
if (process.env.VUE_APP_PREVIEW === 'true') {
// add `ThemeColorReplacer` plugin to webpack plugins
vueConfig.configureWebpack.plugins.push(createThemeColorReplacerPlugin())
}
module.exports = vueConfig
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。