Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('html').use(<Plugin>) first.

报错:

Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('html').use(<Plugin>) first.

  

配置

if (isProd) {
      config
        .plugin("html")
        .tap((args) => {
          args[0].cdn = assetsCDN.assets;
          return args;
        });
    }

  

修改后

const HtmlWebpackPlugin = require("html-webpack-plugin");
 
if (isProd) {
      config
        .plugin("html")
        .use(HtmlWebpackPlugin)
        .tap((args) => {
          args.cdn = assetsCDN.assets;
          return args;
        });
    }

  

args[0].cdn = assetsCDN.assets; // 报错:TypeError: Cannot set property 'cdn' of undefined
 
 
posted @ 2020-12-11 16:25  winyh  阅读(17037)  评论(2编辑  收藏  举报