美文网首页
VUE vue-cli3配置打包后的文件加上版本号

VUE vue-cli3配置打包后的文件加上版本号

作者: 小拇指的约定021 | 来源:发表于2021-06-18 11:52 被阅读0次

const Timestamp = new Date().getTime();

module.exports = {

    // webpack配置

    chainWebpack: config => {

        if (process.env.NODE_ENV === 'production') {

            // 给js和css配置版本号

            config.output.filename('js/[name].' + Timestamp + '.js').end();

            config.output.chunkFilename('js/[name].' + Timestamp + '.js').end();

            config.plugin('extract-css').tap(args => [{

                filename: `css/[name].${Timestamp}.css`,

                chunkFilename: `css/[name].${Timestamp}.css`

            }])

        }

    }

}

打包出来的js中都包含该时间戳,也可以修改成自己想要的标识

参考来源:https://blog.csdn.net/superKM/article/details/102471167?biz_id=102

相关文章

网友评论

      本文标题:VUE vue-cli3配置打包后的文件加上版本号

      本文链接:https://www.haomeiwen.com/subject/rcukyltx.html