webdiscus / html-bundler-webpack-plugin

Alternative to html-webpack-plugin ✅ Renders Eta, EJS, Handlebars, Nunjucks, Pug, Twig templates "out of the box" ✅ Resolves source files of scripts, styles, images in HTML ✅ Uses a template as entry point
ISC License
131 stars 14 forks source link

Upstream issue in `html-minified-terser`: `<meta name="viewport" content="width=device-width initial-scale=1">` is incorrectly minified #106

Open davidmurdoch opened 1 month ago

davidmurdoch commented 1 month ago

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: https://github.com/terser/html-minifier-terser/issues/178

webdiscus commented 1 month ago

@davidmurdoch thanks for the link to the issue.

webdiscus commented 1 month ago

@davidmurdoch

Alternatively, can be used another minify lib.

Just disable build-in minify option: minify: false and use the postprocess callback option with other minify:

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
    }),
  ],
};