-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'tapAsync' of undefined when use @next #1049
Comments
|
same issue working with HtmlWebpackIncludeAssetsPlugin, and I'm using the latest alpha2 version HtmlWebpackIncludeAssetsPlugin instance is after multiple instances of HTMLWebpackPlugin like below glob.sync('views/**/*.html', {cwd: srcPath})
.forEach( (filePath) => {
let chunk = filePath.slice(0, path.extname(filePath).length * -1)
plugins.push(new HTMLWebpackPlugin({
filename: filePath,
template: filePath,
minify: false,
inject: false,
chunks: entry[chunk] ? [ chunk ] : []
}))
})
plugins.push(new HtmlWebpackIncludeAssetsPlugin({
assets: [
{
path: 'client/',
globPath: distPath,
glob: 'vendors*.js'
}
],
append: false
}),) |
The reason for this is that the hook names are changed in html-webpack-plugin 4.x, so plugins will need to be updated to support it. It looks like html-webpack-harddisk-plugin will need updating here:
This was fixed in jharris4/html-webpack-tags-plugin#34 and has now been released in v1.05 of that plugin. |
hi, @edmorley the problem maybe come from html-webpack-inline-source-plugin, and i can't solve it. // webpack.js#L35
if (options.plugins && Array.isArray(options.plugins)) {
for (const plugin of options.plugins) {
console.log(plugin); // result: HtmlWebpackInlineSourcePlugin {}
plugin.apply(compiler);
}
} // html-webpack-inline-source-plugin/index.js#L12
HtmlWebpackInlineSourcePlugin.prototype.apply = function (compiler) {
var self = this;
// Hook into the html-webpack-plugin processing
(compiler.hooks
? compiler.hooks.compilation.tap.bind(compiler.hooks.compilation, 'html-webpack-inline-source-plugin')
: compiler.plugin.bind(compiler, 'compilation'))(function (compilation) {
console.log(compilation.hooks.htmlWebpackPluginAlterAssetTags); // ----- undefined -----
(compilation.hooks
? compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync.bind(compilation.hooks.htmlWebpackPluginAlterAssetTags, 'html-webpack-inline-source-plugin')
: compilation.plugin.bind(compilation, 'html-webpack-plugin-alter-asset-tags'))(function (htmlPluginData, callback) {
if (!htmlPluginData.plugin.options.inlineSource) {
return callback(null, htmlPluginData);
}
var regexStr = htmlPluginData.plugin.options.inlineSource;
var result = self.processTags(compilation, regexStr, htmlPluginData);
callback(null, result);
});
});
}; now, i use this method to ignore the error: // webpack#L35
if (options.plugins && Array.isArray(options.plugins)) {
for (const plugin of options.plugins) {
// so stupid, hahaha
if (JSON.stringify(plugin) === '{}')
continue;
plugin.apply(compiler);
}
} THX~ |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Expected behaviour
no errors.
Current behaviour
Cannot read property 'tapAsync' of undefined
Environment
Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:
Config
Copy the minimal
webpack.config.js
to produce this issue:Copy your template file if it is part of this issue:
Relevant Links
no needs.
Additional contex
while i use html-webpack-plugin@3.2.0, no errors.
when I use @next,
compilation.hooks.
has no html-balabal hooks,please tell me how to fix it, thx U~
The text was updated successfully, but these errors were encountered: