webpack-theme-color-replacer icon indicating copy to clipboard operation
webpack-theme-color-replacer copied to clipboard

与compression-webpack-plugin组件不兼容

Open samulle opened this issue 2 years ago • 3 comments

当项目工程中配置了compression-webpack-plugin压缩组件会导致Handler.js中的assetSource为undefined。 image 应该是js文件被压缩成压缩包了。请问这个有没有什么好的办法解决啊?

samulle avatar Aug 29 '22 11:08 samulle

最好是用服务器(比如nginx)实现gzip,代码还是不要gzip了

hzsrc avatar Sep 10 '22 03:09 hzsrc

构建的时候压缩,nginx优先使用gz文件可以减少服务器压力

问题现象:

使用compression-webpack-plugin,源文件会添加__theme_COLOR_cfg配置,gz压缩文件没有,初步判断是先压缩再添加的,导致加载css文件路径undefined

依赖:

compression-webpack-plugin: ^10.0.0 webpack-theme-color-replacer: ^1.3.26

vue-cli配置:

module.exports = defineConfig({ configureWebpack: { plugins: [ createThemeColorReplacerPlugin() ] }, chainWebpack(config) { config.when(!isDev, config => { config .plugin('compress') .use('compression-webpack-plugin', [ { // { level: 9 } 默认为9 级别越高压缩率越大,压缩时间也就越长 test: /.(js|css|woff|ttf)$/, // 匹配需要压缩的文件后缀 看需求 threshold: 10240 // 大于10kb的会压缩,默认为0 } ]) .end() }) } })

期望:

先添加__theme_COLOR_cfg配置,再执行压缩,或许改下vue-cli配置就可以了

Spacesless avatar Sep 29 '22 03:09 Spacesless

我估计是compression-webpack-plugin先于webpack-theme-color-replacer执行了,导致获取到的是二进制压缩后的数据。这可能没法兼容了

hzsrc avatar Oct 07 '22 16:10 hzsrc

所以 如何解决呢

kekekezi avatar Mar 19 '24 02:03 kekekezi

机制不兼容 

5953107 @.***

 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2024年3月19日(星期二) 上午10:17 收件人: @.>; 抄送: @.>; "State @.>; 主题: Re: [hzsrc/webpack-theme-color-replacer] 与compression-webpack-plugin组件不兼容 (Issue #110)

所以 如何解决呢

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

hzsrc avatar Mar 22 '24 11:03 hzsrc