Skip to content
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 #63

Closed
wzyMaco opened this issue Aug 26, 2019 · 9 comments
Closed

Cannot read property 'tapAsync' of undefined #63

wzyMaco opened this issue Aug 26, 2019 · 9 comments

Comments

@wzyMaco
Copy link

wzyMaco commented Aug 26, 2019

Got the error "Cannot read property 'tapAsync' of undefined"

@morriq
Copy link
Collaborator

morriq commented Aug 26, 2019

Could you share your webpack config and package.json?

@sulkaharo
Copy link

I had this happen when the path to a HTML template was wrong

@EdifierCN
Copy link

HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync
https://github.com/jantimon/html-webpack-plugin/issues/998

@ghost
Copy link

ghost commented Nov 17, 2019

Put HtmlWebpackPlugin in front of WebpackCdnPlugin

// order
new HtmlWebpackPlugin({}),
new WebpackCdnPlugin({}),

@vamsiabishek
Copy link

vamsiabishek commented Dec 3, 2019

Am facing this issue too, i have the following code in my webpack.config file:

const HtmlWebpackPugPlugin = require('html-webpack-pug-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const WebpackCdnPlugin = require('webpack-cdn-plugin')
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin')
const path = require('path')

const mode = process.env.NODE_ENV || 'development'

const config = {
  output: {
    path: path.resolve(__dirname, 'dist'),
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'src/server/views/index.pug'),
      filename: 'index.pug',
      chunks: ['app'],
      alwaysWriteToDisk: true,
    }),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'src/server/views/login.pug'),
      filename: 'login.pug',
      chunks: ['login'],
      alwaysWriteToDisk: true,
    }),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'src/server/views/changePassword.pug'),
      filename: 'changePassword.pug',
      chunks: ['changePassword'],
      alwaysWriteToDisk: true,
    }),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'src/server/views/forgot-password.pug'),
      filename: 'forgot-password.pug',
      inject: false,
      alwaysWriteToDisk: true,
    }),
    new HtmlWebpackPlugin({
      title: 'title',
      cdnModule: 'react',
      template: path.resolve(__dirname, 'src/server/views/layout.pug'),
      filename: 'layout.pug',
      alwaysWriteToDisk: true,
      // other config
    }),
    
    // to add defer to our js script imports
    new ScriptExtHtmlWebpackPlugin({
      defaultAttribute: 'defer',
    }),
    
    // we need this to output pug
    new HtmlWebpackPugPlugin(),
    
    // to use the output pug from the webpack dev server
    new HtmlWebpackHarddiskPlugin({
      outputPath: path.resolve(__dirname, 'views'),
    }),
    new WebpackCdnPlugin({
      modules: {
        react: [
          {
            name: 'react',
            var: 'React',
            path: `umd/react.${mode}.js`,
          },
          {
            name: 'react-dom',
            var: 'ReactDOM',
            path: `umd/react-dom.${mode}.js`,
          },
          {
            name: 'redux',
            var: 'Redux',
            path: 'dist/redux.js',
          },
        ],
      },
    }),
  ],
}

module.exports = config

@sonymaker
Copy link

sonymaker commented Mar 30, 2020

I also have this problem. How can I resolve this problem?
webpack.config.js.txt

@OmriSama
Copy link

Having this issue right now. Really frustrating as this plugin looks very promising.

@shirotech
Copy link
Owner

I'm no longer using this plugin or webpack altogether, PR is welcome to fix this :) and I'll be happy to merge and deploy as soon as possible.

toshiyuki-rs added a commit to toshiyuki-rs/webpack-cdn-plugin that referenced this issue Apr 4, 2020
It was the BREKING CHANGE of renaming tapAsync hook.
fix shirotech#63
toshiyuki-rs added a commit to toshiyuki-rs/webpack-cdn-plugin that referenced this issue Apr 4, 2020
It was the BREKING CHANGE of renaming tapAsync hook.
fix shirotech#63
@rodgco
Copy link

rodgco commented Apr 4, 2020

I've teste @toshiyuki-rs PR and it worked fine.

npm install --save-dev toshiyuki-rs/webpack-cdn-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants