站长资源
中国站长网站

element-ui-admin打包加版本号基于vue-cli4.x

找到vue.config.js

现定义个版本号变量,我这里用光阴戳

const Version = new Date().getTime()

一,增添CSS版本号

css: {
    extract: {
      filename: 'css/[name].css?v=' + Version,
      chunkFilename: 'css/[name].css?v=' + Version
    }
}

二,增添JS版本号

在configureWebpack配置项中增添

output: {
    filename: 'js/[name].js?v=' + Version,
    chunkFilename: 'js/[name].js?v=' + Version
}

三,完整的vue.config.js

'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
const Version = new Date().getTime()
function resolve(dir) {
  return path.join(__dirname, dir)
}
const name = defaultSettings.title // 项偏向题
// 端口
const port = process.env.port || process.env.npm_config_port || 9528

module.exports = {
  publicPath: '/land/', // 项目路径
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    //...
  },
  // css 加版本号
  css: {
    extract: {
      filename: 'css/[name].css?v=' + Version,
      chunkFilename: 'css/[name].css?v=' + Version
    }
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
    // js加版本号
    output: {
      filename: 'js/[name].js?v=' + Version,
      chunkFilename: 'js/[name].js?v=' + Version
    }
  },
  chainWebpack(config) {
    //....
  }
}

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » element-ui-admin打包加版本号基于vue-cli4.x

评论 抢沙发

评论前务必登录!