Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('html').use( ) 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
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM