Skip to content

Add support for preprocessing with node-sass #187

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

Closed
wants to merge 3 commits into from

Conversation

smably
Copy link

@smably smably commented Jun 13, 2018

Inspired by the great work done by @RDGthree in #90, I added some logic to allow a special node-sass syntax type. This adds a step wherein the file is pre-processed by node-sass before being passed as plain CSS to postcss.

This allows the babel plugin to be used with webpack's sass-loader, which uses a custom importer to handle @imports from node_modules. I added an importer config option that takes a single importer or an array of importers. For example:

"plugins": [
  ["react-css-modules", {
    "filetypes": {
      ".scss": {
        "syntax": "node-sass",
        "importer": "node-sass-tilde-importer"
      }
    }
  }]
]

I've also published these changes as a fork (babel-plugin-react-css-modules-sass on npm / https://github.com/smably/babel-plugin-react-css-modules-sass on GitHub).

If there's a chance of this getting merged upstream, I'd be happy to add tests or otherwise clean this up.

@gajus
Copy link
Owner

gajus commented Jun 16, 2018

What issue does this fix that currently cannot be fixed using postcss?

@smably
Copy link
Author

smably commented Jun 16, 2018

@gajus This is to handle sass-loader's custom syntax for imports from node_modules, e.g.:

@import "~bootstrap/dist/css/bootstrap";

I'm not aware of a way do this with postcss alone. I'm guessing that nearly everyone who uses this babel plugin with Sass files will be bundling using sass-loader, so I think it makes sense to use the same pre-processor in the babel plugin as the webpack loader to ensure that the output is in sync.

@smably
Copy link
Author

smably commented Mar 8, 2019

Going to close this out as it's quite old and doesn't look like it's likely to be merged.

@smably smably closed this Mar 8, 2019
@Lighttree
Copy link

Hi, does this project maintained by someone ? This PR fixes quite important issue for Sass users, will this be merged ?

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

Successfully merging this pull request may close these issues.

3 participants