How to use the html-webpack-plugin.version function in html-webpack-plugin

To help you get started, we’ve selected a few html-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KyLeoHC / inline-source-webpack-plugin / index.js View on Github external
apply(compiler) {
    if ('hooks' in compiler) {
      // webpack 4 or higher
      const name = this.constructor.name;
      if (HtmlWebpackPlugin.version >= 4) {
        // HtmlWebpackPlugin 4 or higher
        compiler.hooks.compilation.tap(name, compilation => {
          HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(
            name, // Set a meaningful name here for stack traces
            (data, cb) => {
              this._process(compilation, data, cb);
            }
          );
        });
      } else {
        // HtmlWebpackPlugin 3 or lower
        compiler.hooks.compilation.tap(name, compilation => {
          // if htmlWebpackPlugin is not exist, just do nothing
          if (compilation.hooks.htmlWebpackPluginAfterHtmlProcessing) {
            compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync(
              name,
github SimenB / add-asset-html-webpack-plugin / src / index.js View on Github external
compiler.hooks.compilation.tap('AddAssetHtmlPlugin', compilation => {
      let beforeGenerationHook;
      let alterAssetTagsHook;

      if (HtmlWebpackPlugin.version === 4) {
        const hooks = HtmlWebpackPlugin.getHooks(compilation);

        beforeGenerationHook = hooks.beforeAssetTagGeneration;
        alterAssetTagsHook = hooks.alterAssetTags;
      } else {
        const { hooks } = compilation;

        beforeGenerationHook = hooks.htmlWebpackPluginBeforeHtmlGeneration;
        alterAssetTagsHook = hooks.htmlWebpackPluginAlterAssetTags;
      }

      beforeGenerationHook.tapPromise('AddAssetHtmlPlugin', htmlPluginData =>
        this.addAllAssetsToCompilation(compilation, htmlPluginData),
      );

      alterAssetTagsHook.tap('AddAssetHtmlPlugin', htmlPluginData => {