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

Option for CSS Modules + Preprocessor #24

Closed
iansoper opened this issue Oct 12, 2016 · 20 comments
Closed

Option for CSS Modules + Preprocessor #24

iansoper opened this issue Oct 12, 2016 · 20 comments

Comments

@iansoper
Copy link

I would like an option that would allow you to use CSS Modules + LESS/SASS preprocessor. The loader example is shown here on the react-css-modules repo.
https://github.com/gajus/react-css-modules#sass-scss-less-and-other-css-preprocessors

@iansoper iansoper changed the title Allow CSS Modules + Preprocessor Option for CSS Modules + Preprocessor Oct 12, 2016
@kitze
Copy link
Owner

kitze commented Oct 16, 2016

@iansoper this will be implemented soon.

@DarrylD
Copy link

DarrylD commented Nov 17, 2016

Is this still on the roadmap to be implemented?

@lewisdiamond
Copy link

There's already a pull request for it

@sanfilippopablo
Copy link

Any news on this?

@lewisdiamond
Copy link

#35

@sompylasar
Copy link

@kitze So, what's the status on this? The PR #35 was closed unmerged. We could really make use of the way it was implemented, with _MODULES variables. Which is the way to use SCSS with modules now?

@lewisdiamond
Copy link

@sompylasar You can use this: https://github.com/lewisdiamond/create-react-app/tree/v1.0.1c/packages/react-scripts
I don't guarantee any timely updates on that repo.
Basically remove the current react-scripts from your project and add customizable-react-scripts@1.0.1, then create a config directory and add webpack.custom.{dev|prod}.js and modify what you need from the webpack config.

There's an example in the link I provided.

@sompylasar
Copy link

@lewisdiamond
Copy link

@sompylasar that one is outdated though

@sompylasar
Copy link

@lewisdiamond Where can I find the sources for https://www.npmjs.com/package/custom-react-scripts-with-modules ? I like the simplicity of "env" variables for commonly used features and not dealing with webpack configs (otherwise how is create-react-app different from a hand-rolled webpack config?), so I'd like to fork it and update with the latest upstream fixes such as https://github.com/facebookincubator/create-react-app/pull/2382/files

Why have you decided to go the webpack config route?

@lewisdiamond
Copy link

@sompylasar the source was removed. But it's essentially this pull request: #35

I went for the webpack config route to minimize the changes vs CRA and make it easier to pull upstream changes. It really doesn't have to be any different from using the env file. It's only a function that gets an object and returns an object.

https://github.com/lewisdiamond/create-react-app/tree/v1.0.7c/packages/react-scripts Just copy the config-helpers and use that. It could be integrated in, but CRA will likely come up with solutions to this soon so I don't want to spend too much time on that.

@sompylasar
Copy link

That's unfortunate...

It really doesn't have to be any different from using the env file. It's only a function that gets an object and returns an object.

Well, one or two lines with flags is different than a function and helpers that I need to copy to every project I bootstrap.

Just copy the config-helpers and use that.

This is exactly what I'm trying to avoid. This doesn't scale.

@lewisdiamond
Copy link

@sompylasar make your fork of it and just copy the config helpers in the react-scripts package. It doesn't have to be done for every project. You can also send me a pull request with the config helpers integrated and add a function that adds css modules support. Like I said, I don't want to spend too much time on that since CRA will add support for these things soon. It will probably be JSS.

@sompylasar
Copy link

@lewisdiamond Thanks. I just didn't want to have / make yet another custom react scripts package in the npm; the "custom" one (not "customizable") with env vars and modules served the best, except it's not up to date and doesn't support typescript (for that there is separate which doesn't support everything else). How can we revive it for the sake of zero-config flag-based features? Maybe you could transfer ownership on npm to me if you're not willing to support it...

@lewisdiamond
Copy link

It can be "zero-config" without being strictly flag-based in the env file.

import {addCssModules, addTypeScript, addWhateverElse} from 'customizable-react-scripts/helpers'

export default function(config) {
   addCssModules(config)
   addTypescript(config)
   addWhateverElse(config)
}

The user interface of customizable-react-scripts/helpers is just more basic right now.

You can also fork this repo and add your changes.

@sompylasar
Copy link

That looks better, as long as the "helpers" are in a published maintained module like yours, not copy-pasted into each of the bootstrapped projects from a README.

@lewisdiamond
Copy link

lewisdiamond commented Jul 13, 2017

@sompylasar Like I said before, I don't have time to deal with that. You can send me a pull request that integrates them in and I'll merge.

My fork wasn't meant to be a general use one, I just posted it to help out. CRA will integrate a better solution directly in their repo soon enough.

@sompylasar
Copy link

@lewisdiamond Got it, thanks for your support!

@sompylasar
Copy link

sompylasar commented Jul 14, 2017

Related:

@kitze
Copy link
Owner

kitze commented Aug 10, 2017

I have finally added this in the latest version. You can have any combination of modules + preprocessor by adding module before the file extension. For example: header.module.css or footer.module.less.

Let me know if it works okay 👌

@kitze kitze closed this as completed Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants