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

Expand getLoader method to iterate over rule.loaders and rule.loader when applicable #204

Closed
unconfident opened this issue Feb 18, 2018 · 2 comments

Comments

@unconfident
Copy link
Contributor

Why?

rule.loaders

From documentation:

This option is deprecated in favor of Rule.use.
Rule.loaders is an alias to Rule.use.

rule.loader

For starters, it's still supported by webpack despite what documentation says.

And it's a common, widely present situation in projects depending on CRA. Because whoever ported CRA's configuration to Webpack 2 didn't notice that .extract() method from ExtractTextPlugin returns an array. And so this array still being passed under loader key.

As result postcss-loader cannot be found with getLoader utility method of react-app-rewired in production configuration.

One way to match with webpack's logic is to depend on Webpack's very own internal method RuleSet#normalizeRules and, well, normalize rule set before performing the search. But this has two obvious downsides:

  • It's an internal API and may change in the future
  • It will throw errors if invalid configuration object will be provided
@unconfident
Copy link
Contributor Author

Webpack's very own internal method RuleSet#normalizeRules

I was wrong, instance of webpack's RuleSet class isn't very suitable for needs of this project.

@timarney
Copy link
Owner

Closing this will track under the 2.0 discussion

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

2 participants