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

Adds support for preLoaders in custom webpack config #107

Merged
merged 2 commits into from
Apr 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ exports.default = function (baseConfig, configDir) {
plugins: [].concat((0, _toConsumableArray3.default)(config.plugins), (0, _toConsumableArray3.default)(customConfig.plugins || [])),
module: (0, _extends3.default)({}, config.module, {
// We need to use our and custom loaders.
preLoaders: [].concat((0, _toConsumableArray3.default)(customConfig.module.preLoaders || [])),
loaders: [].concat((0, _toConsumableArray3.default)(config.module.loaders), (0, _toConsumableArray3.default)(customConfig.module.loaders || []))
})
});
Expand Down
3 changes: 3 additions & 0 deletions src/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export default function (baseConfig, configDir) {
module: {
...config.module,
// We need to use our and custom loaders.
preLoaders: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there's a much better generic way to deal with this.
Try this instead of this one. I hope it'll work.

...customConfig.module || {},

If this works, send me a PR with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need on each loader, because if we default to empty object it won't use default config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this won't work, if we do it ^ this way and customConfig.module contains loader it will override loader in config.module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Did you try that, it's add loaders but in the line 62 it'll get override again with the our own loaders?
If that's not working, I'll take this in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see. Sorry I misunderstood, I thought you meant remove whole loaders: [] block too. But this works nicely. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

...customConfig.module.preLoaders || [],
],
loaders: [
...config.module.loaders,
...customConfig.module.loaders || [],
Expand Down