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

Fix loader concatentation bug #173

Merged
merged 1 commit into from
May 9, 2016
Merged

Conversation

stefvhuynh
Copy link
Contributor

This has to do with using custom webpack.config.js files. The code tries to add customConfig.module.loaders. And if customConfig.module is not defined, there is an error.

@stefvhuynh stefvhuynh closed this May 6, 2016
@stefvhuynh stefvhuynh reopened this May 6, 2016
@arunoda
Copy link
Member

arunoda commented May 6, 2016

I need more information. I can't see what this solves anything. This change seems to have no effect on anything.

Am I wrong?

@stefvhuynh
Copy link
Contributor Author

If I have a custom webpack config that looks like this, it'll break:

module.exports = {
  resolves: { extensions: [".jsx"] }
}

I can fix it, by changing it to this:

module.exports = {
  resolves: { extensions: [".jsx"] },
  module: {}
}

Take a look at these lines: https://github.com/kadirahq/react-storybook/blob/master/src/server/config.js#L90-L93

If customConfig.module does not exist, it uses {}. However, on line 93, it expects customConfig.module to be defined (to access customConfig.module.loaders).

@arunoda
Copy link
Member

arunoda commented May 6, 2016

Okay. I got it.
Then the PR should be something like this:

return {
    ...customConfig,
    // We'll always load our configurations after the custom config.
    // So, we'll always load the stuff we need.
    ...config,
    // We need to use our and custom plugins.
    plugins: [
      ...config.plugins,
      ...customConfig.plugins || [],
    ],
    module: {
      ...config.module,
      // We need to use our and custom loaders.
      ...customConfig.module || {},
      loaders: [
        ...config.module.loaders,
        ...customConfig.module? customConfig.module.loaders || [] : {},
      ],
    },
  };

Isn't it?

@stefvhuynh
Copy link
Contributor Author

stefvhuynh commented May 6, 2016

I think instead of {}, you want [] for the second part of the ternary. But whichever way you prefer is how I'll do it (with the ternary or by defining customConfig.module like I did).

@arunoda
Copy link
Member

arunoda commented May 9, 2016

@stefvhuynh Your PR sounds great. I'll do a release within today.

Copy link

nx-cloud bot commented Dec 11, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 01f687d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

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

Successfully merging this pull request may close these issues.

3 participants