1 Star 0 Fork 15

thinkmoreBig / bidDataProject

forked from Vergil / bidDataProject 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
Vergil 提交于 2021-05-17 14:52 . feat:修改需求
const path = require('path');
// cnpm run build --report检测包大小
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CompressionWebpackPlugin = require('compression-webpack-plugin');// 启用gzip
// 默认设置压缩图片
// const defaultOptions = {
// bypassOnDebug: true
// };
// 自定义设置压缩图片
const customOptions = {
mozjpeg: {
progressive: true,
quality: 50
},
optipng: {
enabled: true,
},
pngquant: {
quality: [0.5, 0.65],
speed: 4
},
gifsicle: {
interlaced: false,
},
// 不支持WEBP就不要写这一项
webp: {
quality: 75
}
};
function resolve (dir) {
return path.join(__dirname, dir);
}
const vueConfig = {
productionSourceMap: true, // 加速生产环境构建 打包时候不会出现.map文件
// 简单配置
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
return {
plugins: [
new BundleAnalyzerPlugin(), // 检测包大小
new CompressionWebpackPlugin()// 启用gzip配合nginx
]
};
}
},
// 精细配置
chainWebpack: config => {
// 压缩图片
config.module.rule('images')
.test(/\.(gif|png|jpe?g|svg)$/i)
.use('image-webpack-loader')
.loader('image-webpack-loader')
.options(customOptions)
.end();
config.resolve.alias
.set('@', resolve('src'));
}
};
module.exports = vueConfig;
JavaScript
1
https://gitee.com/thinkmore-big/bid-data-project.git
git@gitee.com:thinkmore-big/bid-data-project.git
thinkmore-big
bid-data-project
bidDataProject
master

搜索帮助