-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Decide what to do with the HTML minification feature #1036
Comments
Your points are great 👍 So we have three possible ways to go here:
|
Ah good point about |
We should try to use only safe options - maybe we can reuse the create-react-app settings? |
I've updated the issue title given the choice of direction has changed - or at least is TBD :-)
Neutrino uses (though I've been meaning to see whether we should update this list): The options reference is here: Using any option that isn't used by the projects above is probably risky, since (a) they probably had good reason not to enable it, (b) it's not getting as much real-world coverage. Reviewing the options used at least once by the projects above:
As such, how about this? minify: {
collapseWhitespace: true,
// See: https://github.com/jantimon/html-webpack-plugin/issues/1036#issuecomment-421577653
// conservativeCollapse: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
} (This would just be for when webpack |
Wow this is really really awesome 👍 |
One other thing we would need to decide, is whether any user-provided |
So I would propose to have the following mapping for the simple cases:
Now for the object notation it's harder to decide. I would rather go for explicit over implicit and not merge it (you would just get what you configured and nothing else). We could also add a new property to allow the preset:
However if most users expect it to be merged we can also merge it. |
The true/false/undefined proposal above sounds great. |
Perfect 👍 👍 |
I'm happy to put together a PR, unless you're already working on it? |
I haven't started yet so sure go for it! :) Please use the version 4 branch: |
Looking at <!DOCTYPE html>
<html>
<head></head>
<body>
<div>
<span>foo</span> <span>bar</span>
</div>
</body>
</html> ...and there is still a space between the two In addition:
As such, I think we should just use standard |
Previously minification was disabled by default. Now, if `minify` is `undefined` and `mode` is `'production'`, then it is enabled using the following options: ``` { collapseWhitespace: true, removeComments: true, removeRedundantAttributes: true, removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, useShortDoctype: true } ``` These options were based on the settings used by create-react-app, Neutrino and vue-cli, and are hopefully fairly conservative. See: #1036 (comment) https://github.com/kangax/html-minifier#options-quick-reference These same defaults can enabled regardless of `mode`, by setting `minify` to `true` (which previously passed an empty object to html-minifier, meaning most minification features were disabled). Similarly, minification can be disabled even in production, by setting `minify` to `false`. This change has no effect on users who pass an object to `minify`. Fixes #1036.
This was fixed by #1048. |
Released in 4.0.0-beta.1 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
html-webpack-plugin
has aminify
option that provides support for minifying the generated HTML.However:
false
) so unless people manually enable it, isn't used) in case people do want to minify
html-webpack-plugin
has some issues (eg Uglify fails silently when passed in incorrect options #743)Describe the solution you'd like
For the minify feature and the dependency on the
html-minifier
package to be removed in the next major version ofhtml-webpack-plugin
(ie v4 on thewebpack-4
branch).This idea was previously mentioned in #558 and #452.
Describe alternatives you've considered
Leaving the
html-minifier
dependency as-is in v4.Additional context
N/A
The text was updated successfully, but these errors were encountered: