html-webpack-plugin打包报错

Posted 夏小夏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html-webpack-plugin打包报错相关的知识,希望对你有一定的参考价值。

打包报错
TypeError: Cannot read property \'tap\' of undefined

at htmlWebpackPlugin.apply (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\html-webpack-plugin\\index.js:40:31)
at WebpackCLI.webpack (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\webpack\\lib\\webpack.js:51:13)
at WebpackCLI.createCompiler (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\webpack-cli\\lib\\webpack-cli.js:1845:29)
at async WebpackCLI.buildCommand (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\webpack-cli\\lib\\webpack-cli.js:1952:20)
at async Command.<anonymous> (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\webpack-cli\\lib\\webpack-cli.js:742:25)
at async Promise.all (index 1)
at async Command.<anonymous> (D:\\MyData\\xiamy9\\study\\webpack-study\\node_modules\\webpack-cli\\lib\\webpack-cli.js:1289:13)

发现是版本问题:webpack4 和 html-webpack-plugin5配合使用了,需要将webpack升级或者html-webpack-plugin降级 。

以上是关于html-webpack-plugin打包报错的主要内容,如果未能解决你的问题,请参考以下文章

webpack插件之html-webpack-plugin

webpack中使用html-webpack-plugin生成HTML文件并主动插入css和js引入标签

webpack 打包时到底如何组织js

一看就懂之 webpack 高级配置与优化

详解html-webpack-plugin配置

[js高手之路]深入浅出webpack教程系列4-插件使用之html-webpack-plugin配置(上)