Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Support both global and local style? #372

Closed
wants to merge 1 commit into from
Closed

Support both global and local style? #372

wants to merge 1 commit into from

Conversation

thedv91
Copy link

@thedv91 thedv91 commented Jan 6, 2019

@thedv91
Copy link
Author

thedv91 commented Jan 12, 2019

I think our project needs both global style and local style.
Can make more flexible?

@thedv91 thedv91 changed the title Remove cssModules from options Support both global and local style? Jan 12, 2019
@rauchg rauchg added the wip label Jan 31, 2019
@felixmosh
Copy link

felixmosh commented Apr 21, 2019

It can be simplified by using the oneOf webpack feature.

I've managed to change the config from outside by using this in next.config.js file:

config.module.rules.forEach(rule => {
  if (rule.test.toString().includes('.scss')) {
    rule.rules = rule.use.map(useRule => {
      if (typeof useRule === 'string') {
        return {
          loader: useRule,
        };
      }
      if (useRule.loader.startsWith('css-loader')) {
        return {
          oneOf: [
            {
              test: /\.global\.scss$/,
              loader: useRule.loader,
              options: {
                ...useRule.options,
                modules: false,
              },
            },
            {
              loader: useRule.loader,
              options: useRule.options,
            },
          ],
        };
      }

      return useRule;
    });

    delete rule.use;
  }
});

@thedv91 WDYT?

@thedv91
Copy link
Author

thedv91 commented May 3, 2019

@felixmosh yep I think we can customize next.config.js but I want to support options from packages

@jlmakes
Copy link

jlmakes commented May 18, 2019

Damn @felixmosh that should be a part of the docs.

@felixmosh
Copy link

I want it to be part of next-scss/css :)

@bez4pieci
Copy link

Please add this, it is super useful during migration to CSS Components.

@icewheel
Copy link

this is the missing feature that will be very helpful.

@timneutkens
Copy link
Member

I'm going to close this in favor of vercel/next.js#8626

Thanks for your contribution 🙏

@warriv93
Copy link

warriv93 commented May 5, 2020

Great work, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants