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

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

作者: 蕉下客_661a | 来源:发表于2021-04-09 10:22 被阅读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`
            }])
        }
    },
    css: {
        loaderOptions: {
            sass: {
                // 向全局sass样式传入共享的全局变量
                data: `@import "@/styles/public.scss";@import "@/styles/element_ui_style.scss";`
            }
        }
    },
    lintOnSave: false,
    productionSourceMap: true,

    //是开发模式的时候,获取当前路径下的地址,是测试或者开发模式的时候,用/获取地址
    publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
}
image.png

相关文章

网友评论

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

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