代码拉取完成,页面将自动刷新
const CompressionPlugin = require('compression-webpack-plugin')
// const SentryCliPlugin = require('@sentry/webpack-plugin')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const externals = {
/* 调试免构建 */
dev: {
vue: 'Vue',
'vue-router': 'VueRouter',
'view-design': 'iview',
axios: 'axios'
},
/* 上线免构建 */
build: {
vue: 'Vue',
'vue-router': 'VueRouter',
'view-design': 'iview',
axios: 'axios'
}
}
const cdn = {
dev: {
css: [
'https://cdn.staticfile.org/view-design/4.7.0/styles/iview.css'
],
js: [
'https://cdn.staticfile.org/vue/2.6.14/vue.runtime.min.js',
'https://cdn.staticfile.org/vue-router/3.5.3/vue-router.min.js',
'https://cdn.staticfile.org/axios/0.21.1/axios.min.js',
'https://cdn.staticfile.org/view-design/4.7.0/iview.min.js'
]
},
build: {
css: [
'https://cdn.staticfile.org/view-design/4.7.0/styles/iview.css'
],
js: [
'https://cdn.staticfile.org/vue/2.6.14/vue.runtime.min.js',
'https://cdn.staticfile.org/vue-router/3.5.3/vue-router.min.js',
'https://cdn.staticfile.org/axios/0.21.1/axios.min.js',
'https://cdn.staticfile.org/view-design/4.7.0/iview.min.js'
]
}
}
const IS_PROD = process.env.NODE_ENV === 'production'
module.exports = {
publicPath: IS_PROD ? process.env.BASE_URL : '/',
assetsDir: process.env.VUE_APP_VERSION,
lintOnSave: true,
productionSourceMap: !IS_PROD,
devServer: {
port: 1111,
host: '0.0.0.0',
open: 'Cent Browser',
compress: true,
disableHostCheck: true,
proxy: {
'^/api': {
target: process.env.VUE_APP_API_URL,
ws: true,
changeOrigin: true,
pathRewrite: {
// 取消api代理
'^/api': '/'
}
}
}
},
parallel: require('os').cpus().length > 1,
chainWebpack: config => {
config.plugins.delete('prefetch')
config.plugins.delete('preload')
config.plugin('html').tap(args => {
if (IS_PROD) {
args[0].cdn = cdn.build
} else {
args[0].cdn = cdn.dev
}
return args
})
},
configureWebpack: config => {
config.externals = externals[IS_PROD ? 'build' : 'dev']
// config.plugins.push(new BundleAnalyzerPlugin())
if (IS_PROD) {
config.optimization.minimize = true
if (process.env.VUE_APP_VERSION !== 'debug') {
/* config.plugins.push(new SentryCliPlugin({
include: './dist',
release: process.env.VUE_APP_VERSION
})) */
}
config.plugins.push(
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
threshold: 10240,
minRatio: 0.8,
cache: true
})
)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。