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

The CopyWebpackPlugin is undefined #331

Closed
robinvdvleuten opened this issue Aug 21, 2017 · 4 comments
Closed

The CopyWebpackPlugin is undefined #331

robinvdvleuten opened this issue Aug 21, 2017 · 4 comments

Comments

@robinvdvleuten
Copy link

robinvdvleuten commented Aug 21, 2017

Do you want to request a feature or report a bug?

bug

What is the current behavior?

When I call the getPlugins helper, an array of all used plugins is returned. But it doesn't seem to contain the CopyWebpackPlugin.

If the current behavior is a bug, please provide the steps to reproduce.

export default function (config, env, helpers) {
  console.log(helpers.getPluginsByName(config, 'CopyWebpackPlugin'));
}

What is the expected behavior?

I expect an array containing the CopyWebpackPlugin.

Please mention other relevant information.

  • node version: v8.1.1
  • npm version: v5.2.0
  • Operating system: osx
@SaraVieira
Copy link
Contributor

Hi @robinvdvleuten ,

The preact cli does not use that webpack plugin , if you need it you may need to add it by pushing into the config.plugins array in your preact-config.js

Here you can see the CLI's webpack : https://github.com/developit/preact-cli/blob/master/src/lib/webpack/webpack-base-config.js

@reznord reznord closed this as completed Aug 21, 2017
@robinvdvleuten
Copy link
Author

@SaraVieira but there is one in https://github.com/developit/preact-cli/blob/master/src/lib/webpack/webpack-client-config.js#L76 Aren't these merged when building with webpack?

@developit
Copy link
Member

Ah - custom config is actually run twice - once against the SSR/prerender configuration, and once against the client configuration. CopyWebpackPlugin is only in the client configuration, so you'll want to existence-test for it when trying to pull it out of the config:

export default function (config, env, helpers) {
  let copyPlugin = helpers.getPluginsByName(config, 'CopyWebpackPlugin');
  if (copyPlugin) {
    // ..
  }
}

@robinvdvleuten
Copy link
Author

I also managed to solve it by just adding the plugin myself within a custom config file 👍

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

4 participants