-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Upstream issue in html-minifier-terser
: <meta name="viewport" content="width=device-width initial-scale=1">
is incorrectly minified
#106
Comments
@davidmurdoch thanks for the link to the issue. |
Alternatively, can be used another minify lib. Just disable build-in minify option: const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
const myMinify = require('ANY-MINIFY-PACKAGE'); // <= install another minify package
module.exports = {
plugins: [
new HtmlBundlerPlugin({
entry: {
index: './src/home.html',
},
minify: false, // <= disable build-in minify
postprocess: (content) => myMinify(content), // <= use custom minify function
}),
],
}; |
…26268) The functionality is the same as before, but it this change works around a bug in https://github.com/terser/html-minifier-terser which causes the space to be removed, and the tag to become invalid (this only affects the webpack build). Upstream issues: webdiscus/html-bundler-webpack-plugin#106 terser/html-minifier-terser#178
…26268) The functionality is the same as before, but it this change works around a bug in https://github.com/terser/html-minifier-terser which causes the space to be removed, and the tag to become invalid (this only affects the webpack build). Upstream issues: webdiscus/html-bundler-webpack-plugin#106 terser/html-minifier-terser#178
Valid property separators are also comma or semicolon. |
thanks to @vralle, provided an example of using more efficient and faster HTML minimizer html-minimizer-webpack-plugin plugin with the @swc/html module, which keep the const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
import HtmlMinimizerPlugin from 'html-minimizer-webpack-plugin';
module.exports = {
plugins: [
new HtmlBundlerPlugin({
entry: {
index: './src/index.html',
},
minify: false, // <= disable build-in minify
}),
],
optimization: {
minimizer: [
new HtmlMinimizerPlugin({
minify: HtmlMinimizerPlugin.swcMinify, // <= requires additional `@swc/html` package
minimizerOptions: {
quotes: false,
tagOmission: false, // <= this option must be `false` to keep head and body tags
},
}),
],
},
}; The generated minified HTML containing valid <!doctype html><html><head><meta name=viewport content="width=device-width initial-scale=1">
<link href=css/home.bundle.css rel=stylesheet><script src=js/main.bundle.js></script></head><body><h1>Hello World!</h1></body></html> Here is the test case used |
html-minified-terser
: <meta name="viewport" content="width=device-width initial-scale=1">
is incorrectly minifiedhtml-minifier-terser
: <meta name="viewport" content="width=device-width initial-scale=1">
is incorrectly minified
Just linking it here so it can be more easily tracked, and others that might be affected when using
html-bundler-webpack-plugin
can more easily find it here.Upstream issue: terser/html-minifier-terser#178
The text was updated successfully, but these errors were encountered: