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

Allow overriding Webpack module rules #291

Merged
merged 1 commit into from Aug 1, 2023
Merged

Conversation

mrm007
Copy link
Contributor

@mrm007 mrm007 commented Jul 27, 2023

See changeset for details.

@mrm007 mrm007 requested a review from a team as a code owner July 27, 2023 01:35
@changeset-bot
Copy link

changeset-bot bot commented Jul 27, 2023

🦋 Changeset detected

Latest commit: 078adf5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
playroom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@askoufis askoufis merged commit a044864 into master Aug 1, 2023
7 checks passed
@askoufis askoufis deleted the allow-webpack-overrides branch August 1, 2023 05:33
@pascalduez
Copy link
Contributor

pascalduez commented Aug 25, 2023

Hello,

this should probably have been released as a major version?
It breaks our current implementation.

ERROR in ./components/FrameComponent.js 11:4

Module parse failed: Unexpected token (11:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| export default function Root(props) {
|   return (
>     <div>

Investigating.

Our stripped down config.

module.exports = {
  components: './components/components',
  frameComponent: './components/FrameComponent.js',
  webpackConfig: () => ({
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: [
            {
              loader: 'babel-loader',
              options: {
                targets: { browsers: 'defaults', esmodules: true },
                // Our config with all the proper js, react etc. plugins.
                presets: ['@our/config'],
              },
            },
          ],
        },
      ],
    },
  }),
};

EDIT: actually even without having any rules defined this breaks.
As soon as you have webpackConfig.

EDIT 2:
I can fix the .js rule by adding include: [path.resolve('./components')] (where FrameComponent lives).
Looks like the include key is properly merged.
But this does not work for a .css rule.

@mrm007
Copy link
Contributor Author

mrm007 commented Sep 4, 2023

Hi @pascalduez,

Overriding Playroom's Webpack loaders means you have to provide support for processing JSX in your JS/TS files. Playroom merges its default config with yours, overwriting Playroom's module.rules with yours. This is an escape hatch for when you need to do something more complex than what Playroom provides out of the box. The caveat is that you have to recreate what Playroom provides out of the box.

If you have a reproducible example of this not working, I'd be happy to take a look.

@rbardini
Copy link
Contributor

This change breaks my build too:

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> .storybook-button {
|   font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|   font-weight: 700;

even though I have the following rule:

{
  test: /\.css$/,
  include: path.resolve(__dirname, 'src'),
  use: ['style-loader', 'css-loader'],
}

v0.32.0 works with the config above.

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.

None yet

4 participants