当前位置:网站首页>Vue program of web cache problem after packaging
Vue program of web cache problem after packaging
2022-08-08 18:44:00 【AwoCT】
1、设置html
在入口文件 /public/index.html
中,head 标签中,添加
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
2、配置vue.config.js
const Timestamp = new Date().getTime()
module.exports = {
productionSourceMap: false, // false : 不生成map文件
css: {
loaderOptions: {
postcss: {
plugins: [
require('postcss-plugin-px2rem')({
rootValue: 75, //px换算rem基数,100也就是 100px换算成1rem
// unitPrecision: 5, //允许REM单位增长到的十进制数字.
//propWhiteList: [], //默认值是一个空数组,这意味着禁用白名单并启用所有属性.
// propBlackList: [], //黑名单
exclude: /(node_module)/, //默认false,可以(reg)利用正则表达式排除某些文件夹的方法,例如/(node_module)\/如果想把前端UI框架内的px也转换成rem,请把此属性设为默认值
// selectorBlackList: [], //要忽略并保留为px的选择器
// ignoreIdentifier: false, //(boolean/string)忽略单个属性的方法,启用ignoreidentifier后,replace将自动设置为true.
// replace: true, // (布尔值)替换包含REM的规则,而不是添加回退.
mediaQuery: false, //(布尔值)允许在媒体查询中转换px.
minPixelValue: 3 //设置要替换的最小像素值(3px会被转rem). 默认 0
})
]
}
},
extract: {
/** * 一、打包后的css with version number,Do not change the file name. * filename: `css/[name].css?v=${Timestamp}` * chunkFilename: `css/[name].css?v=${Timestamp}` */
/** * 二、一种方式,After each packagecssThe file name will be updated. */
filename: `css/[name].${
Timestamp}.css`,
chunkFilename: `css/[name].${
Timestamp}.css`
}
},
chainWebpack(config) {
// 配置svg =======> svg-sprite-loader
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.test(/\.svg$/)
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
},
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.mode = 'production';
config["performance"] = {
//打包文件大小配置
"maxEntrypointSize": 10000000,
"maxAssetSize": 3000000000
}
}
config.output.filename = `js/[name].${
Timestamp}.js`
config.output.chunkFilename = `js/[name].${
Timestamp}.js`
}
}
3、打包
终端输入:npm run build
结果如下:
边栏推荐
- 为什么需要交叉编译器
- DHCP服务初探
- HCIP第十三天作业——综合实验
- CF187C(堆优化BFS)
- 我们想更换RDS数据库,从sqlserver 2016 web升级到 2017企业集群版,有专家咨询
- 2 prerequisites for successful "digital transformation" of enterprises!
- SSH协议抓包-工具Wireshark
- Transsion Holdings: At present, there is no clear plan for the company's mobile phone products to enter the Chinese market
- 重读GPDB 和 TiDB 论文引发的 HTAP 数据库再思考
- TensorFlow学习记录(七):生成对抗网络
猜你喜欢
随机推荐
数据压缩和归档(三)、tarfile
传音控股:目前公司手机产品暂无明确计划进入中国市场
面试突击:输入URL之后会执行什么流程?
在线支付,出款和收款
The origin and creation of Smobiler's complex controls
【Promise.allSettled】手写Promise.allSettled方法
一起了解分层架构&SOA架构
2021年9月电子学会图形化二级编程题解析含答案:画正多边形
This error is reported when the shake database is started. Is there a problem with the configuration?
智文最终版本
el-tree设置单选,点击完成后收起
what‘s the meaning of xenial
CS231n:11 生成模型
what's the meaning of xenial
为啥程序员下班后只关显示器从不关电脑?看看各大网站的答案~
Numpy函数、模块、类列表
2021年9月电子学会图形化三级编程题解析含答案:绘制图形
CS231n:12 强化学习
CF533B(树形dp+转移技巧)
浅谈C语言简单实现二分查找