webpack打包报错如下:

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

解决方法:

修改vue.config.js原配置:

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;
        });
    }
Logo

前往低代码交流专区

更多推荐