vue.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. // see https://www.jianshu.com/p/b358a91bdf2d
  2. // https://www.jianshu.com/p/483c0c3d932e
  3. // import CompressionWebpackPlugin from 'compression-webpack-plugin'
  4. // 是否为生产环境
  5. // const isProduction = process.env.NODE_ENV !== 'development'
  6. // gzip压缩
  7. // eslint-disable-next-line @typescript-eslint/no-var-requires
  8. // const CompressionWebpackPlugin = require('compression-webpack-plugin')
  9. module.exports = {
  10. publicPath: './', // 目录路径
  11. outputDir: 'dist', // 文件名
  12. assetsDir: 'static', // 静态文件名
  13. indexPath: 'index.html', // 首页路径
  14. filenameHashing: true, // has值
  15. productionSourceMap: false // 不需要map文件
  16. // configureWebpack: (config) => {
  17. // // 生成环境压缩文件
  18. // if (isProduction) {
  19. // // gzip压缩
  20. // const productionGzipExtensions = ['html', 'js', 'css']
  21. // config.plugins.push(
  22. // new CompressionWebpackPlugin({
  23. // filename: '[path].gz[query]',
  24. // algorithm: 'gzip',
  25. // test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  26. // threshold: 5120, // 只有大小大于该值的资源会被处理 5120
  27. // minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
  28. // deleteOriginalAssets: false // 删除原文件
  29. // })
  30. // )
  31. // }
  32. // } // 压缩文件
  33. }