1 Star 0 Fork 10

王新斌/ waynboot-mobile

forked from waynaqua/ waynboot-mobile 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vue.config.js 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
waynaqua 提交于 2023-07-18 23:40 . 代码优化
'use strict'
const path = require('path')
const port = process.env.port || process.env.npm_config_port || 4949
const baseUrl = process.env.VUE_APP_BASE_URL
function resolve(dir) {
return path.join(__dirname, dir)
}
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
publicPath: '/mall',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'/dev-api': {
target: baseUrl,
pathRewrite: {
'^/dev-api': '/'
},
secure: false,
changeOrigin: true
},
'upload': {
target: baseUrl,
secure: false,
changeOrigin: true
}
}
},
configureWebpack: {
devtool: 'source-map',
name: 'panda-mall',
resolve: {
alias: {
'@': resolve('src')
}
},
// 打包配置
performance: {
hints: 'warning',
// 入口起点的最大体积 整数类型(以字节为单位)
maxEntrypointSize: 50000000,
// 生成文件的最大体积 整数类型(以字节为单位 300k)
maxAssetSize: 30000000,
// 只给出 js 文件的性能提示
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js')
}
}
},
chainWebpack(config) {
// it can improve the speed of the first screen, it is recommended to turn on preload
config.plugin('preload').tap(() => [
{
rel: 'preload',
// to ignore runtime.js
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: 'initial'
}
])
// when there are many pages, it will cause too many meaningless requests
config.plugins.delete('prefetch')
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
.end()
config.when(process.env.NODE_ENV !== 'development', config => {
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk('single')
})
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/meiyia/waynboot-mobile.git
git@gitee.com:meiyia/waynboot-mobile.git
meiyia
waynboot-mobile
waynboot-mobile
master

搜索帮助