Skip to content

v4.0.0

Latest
Compare
Choose a tag to compare
@webdiscus webdiscus released this 08 Sep 18:01
· 4 commits to master since this release
e30c8c4

v4.0.0

BREAKING CHANGES

  • Supports Node.js version 18+.

  • Supports Webpack version 5.81+.

  • The plugin option property is not static anymore:

    OLD (up to v3.x)

    class MyPlugin extends HtmlBundlerPlugin {
      constructor(options = {}) {
        super({ ...options });
      }
      init(compiler) {
        // MyPlugin.option. ...; <= was as static property
      }
    }

    NEW (since v4.0)

    class MyPlugin extends HtmlBundlerPlugin {
      constructor(options = {}) {
        super({ ...options });
      }
      init(compiler) {
        // this.option. ...; <= now is non static property
      }
    }
  • Using the addProcess() plugin method is changed:

    OLD (up to v3.x)

    class MyPlugin extends HtmlBundlerPlugin {
      constructor(options = {}) {
        super({ ...options });
      }
      init(compiler) {
        // the method was as property of the static `option`
        MyPlugin.option.addProcess('postprocess', (content) => {
          return content;
        });
      }
    }

    NEW (since v4.0)

    class MyPlugin extends HtmlBundlerPlugin {
      constructor(options = {}) {
        super({ ...options });
      }
      init(compiler) {
        // now is the class method
        this.addProcess('postprocess', (content) => {
          return content;
        });
      }
    }

DEPRECATIONS

  • The watchFiles.files option has been renamed to watchFiles.includes.
    The files option is still supported but is deprecated.
    It's recommended to replace the files with includes in your config.

  • The watchFiles.ignore option has been renamed to watchFiles.excludes.
    The ignore option is still supported but is deprecated.
    It's recommended to replace the ignore with excludes in your config.

FEATURES

  • Added support the multiple webpack configuration:
const path = require('path');
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin');

module.exports = [
  {
    name: 'first',
    output: {
      path: path.join(__dirname, 'dist/web1/'),
    },
    plugins: [
      new HtmlBundlerPlugin({
        entry: {
          index: './web1/views/home.html',
        },
      }),
    ],
  },

  {
    name: 'second',
    output: {
      path: path.join(__dirname, 'dist/web2'),
    },
    plugins: [
      new HtmlBundlerPlugin({
        entry: {
          index: './web2/views/home.html',
        },
      }),
    ],
  },
];
  • Display webpack config name in console output:
    module.exports = {
      name: 'client', // <= this name will displayed in console output
    }

BUGFIX

  • Fixed ERROR in RealContentHashPlugin in serv/watch mode after adding new import file.
  • Fixed ERROR in RealContentHashPlugin when using integrity in serv/watch mode after changes by using dynamic import.

MISC

  • Refactored all static classes to regular, this is needed to support webpack multiple configurations.
  • Updated dev packages, many packages requires Node.js >= v18.