vue-config.js

本文探讨了Webpack的配置细节,包括设置应用名称、性能优化如限制入口点大小,以及使用StyleLint进行代码检查。同时,配置了Workbox生成Service Worker实现离线缓存,并针对图片进行了缓存策略的定制。虽然未启用多进程打包,但通过阈值和压缩率设置了资源处理条件。

configureWebpack: {
// provide the app’s title in webpack’s name field, so that
// it can be accessed in index.html to inject the correct title.
performance: {
maxEntrypointSize: 400000
},
name: name,
resolve: {
alias: {
‘@’: resolve(‘src’)
}
},
plugins: [
new StyleLintPlugin({
‘files’: [’**/*.{html,vue,css,sass,scss}’],
‘fix’: false,
‘cache’: true,
‘emitErrors’: true,
‘failOnError’: false
}),
// 暂时用不到多进程打包,得不偿失。
// new SpeedMeasurePlugin({
// module: {
// rules: [
// {
// test: /.jsKaTeX parse error: Expected 'EOF', got '}' at position 58: … // }̲ // ]…
),
threshold: 10240, // 只有大小大于该值的资源会被处理 10240
minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
deleteOriginalAssets: false // 删除原文件
}) : () => {},
new WorkboxPlugin.GenerateSW({
// Do not precache images
exclude: [/.(?:png|jpg|jpeg|svg)KaTeX parse error: Can't use function '\.' in math mode at position 169: … urlPattern: /\̲.̲(?:png|jpg|jpeg…/,
// Apply a cache-first strategy.
handler: ‘CacheFirst’,
options: {
// Use a custom cache name.
cacheName: ‘images’,
// Only cache 10 images.
expiration: {
maxEntries: 10
}
}
}]
})
]
},

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值