-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use emit
event instead of this-compilation
#71
Conversation
Given that compression is most likely one of the last steps on the pipeline chain, it makes sense that this plugin uses the `emit` event which is the last step to add/modify assets before they're written to disk. This plays nicely with other plugins that create and delete files on the fly AFTER they're compiled (for example https://github.com/jtefera/merge-files-webpack, which is the recommeded solution for this issue webpack-contrib/extract-text-webpack-plugin#179)
emit
event instead of this-compilation
Marked as (:label: Minor) for now, but not 💯 if this should be considered a breaking change, personally I don't think so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Whats holding up this from being pulled? |
With this config my js gets compressed but not my HTML why ?? |
@NitroBAY compression just create |
Yes I know but it creates a js file with its gz counterpart but the html file created by HtmlWebpackPlugin (shorten by HtmlPlugin here) is not having its gz version of it. I missing something because I'm new to webpack maybe but then what is it ? |
Even without htmlplugin but with file-loader/extract-loader :
The output html is not gzipped is it normal ? How do I gzip html ? |
@NitroBAY seems you have default |
@evilebottnawi the default is 0 bytes. My html is not 130 bytes so it's greater than 0. Even when I set to 1 or whatever value it doesn't change a thing. Ratio has been also set to 0.
|
Any solutions to that? I just want the |
I've resolved this issue by implementing this plugin: html-webpack-change-assets-extension-plugin. Eg: plugins: [
new HtmlWebpackPlugin({
jsExtension: ".gz"
}),
new CompressionPlugin(), // compression plugin will generate the xxx.js.gz file
new HtmlWebpackChangeAssetsExtensionPlugin()
]; Please create an issue here if you encounter any issues related to that plguin. |
@nerdmax Thx! Using it and it works! I read quite a few issues that was being closed, for instance jantimon/html-webpack-plugin#61 I just want to clarify my need. Using only
I get:
But then the output html isn't using the gz:
no matter which order I use HtmlWebpackPlugin and CompressionPlugin. But with:
I have:
Anyway, HtmlWebpackChangeAssetsExtensionPlugin worked for my use case. |
Is it me or is this simply broken with webpack v5? Running
I get
Node 14 In html-webpack-plugin |
This is my webpack config by the way:
|
Notable Changes
Given that compression is most likely one of the last steps on the pipeline
chain, it makes sense that this plugin uses the
emit
event which is the laststep to add/modify assets before they're written to disk.
This plays nicely with other plugins that create and delete files
on the fly AFTER they're compiled
(for example https://github.com/jtefera/merge-files-webpack, which is the
recommeded solution for this issue
webpack-contrib/extract-text-webpack-plugin#179)
Issues