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