-
Notifications
You must be signed in to change notification settings - Fork 47
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
support pre-proccessors like LESS or SASS #14
Comments
You're correct. Currently we only address It might be worth looking into how |
👍 |
👍 |
👍 this would make the plugin worthwhile for me! |
thanks everyone for showing your interest here! To move this forward I'd like to get a more tangible idea of what kind of "support" people are hoping for. For starters could you please all reply to this thread with an answer to these questions:
Thanks |
|
One idea is to use one of the following PostCSS plugin packs instead of Sass: There's a good chance one of them has all the features you need. |
I'm looking to leverage the vast amount of community frameworks and libraries built already in SASS (less/stylus etc). Rewriting various tooling and reinventing entire libraries just to use modular CSS is just not practical. I worked around the limitation by just porting the particular project that prompted this issue to use Webpack, where modular CSS works just fine with other pre-processors. It would be much better to allow users of browserify to also have access to the same functionality. 😸 |
@pho3nixf1re agreed. is there an example we can see of where you're using it with webpack? That will help to drive the discussion. My personal experience so far is the same as @rtsao, in that most of the things I would normally want from less/sass/stylus is also achievable with postcss plugins. So I'm interested to learn more about other peoples' experiences and use-cases for preprocessors, and I think you've mentioned a good one in being able to easily use frameworks/libraries. |
|
thanks @joezimjs - would you be happy to create an example github repo that demonstrates the kind of usage you're after? That will really help in this discussion. |
Are you looking for how I'd use Stylus or how I'd like the build CSS Module builds to work with the preprocessor? |
Yeah I think it would be helpful to create a repo that shows how you would like Stylus + CSS Modules to work together. Consider it as a failing test case. |
I've created an example repo of how a simple project using stylus + CSS modules could look. There are a few problems relating to how to implement the loading of the stylus files (see the README). |
@romeovs cool, thanks! Have you had a look at the possibility of using things like https://github.com/DamonOehlman/stylify or https://github.com/morlay/stylus-browserify ? |
Will stylify work with css-modulesify? I'm not sure this plugin works exactly or how Browserify plugins work in general, so will it be able to take the CSS output of stylify and then do its thing with that? How will it know that it should do anything to a stylus file since it isn't .css? I can't test it because currently css-modules-loader doesn't work on Windows. |
A bigger problem would be that css-modulesify needs the modules as separate files to be able to generate the correct "private" names. When you hand it the (single, compiled) file stylus generates, the names will be inconsistent with the names that are exported to javascript. |
I'm not sure I would call that a "bigger problem" because if you can't get css-modulesify to work with the stylus files at all, that seems worse. It's certainly a large concern though. WebPack seems to really get things right with their stream of loaders, but right now I can't get it to load my CSS/Stylus files (stupid "Cannot resolve module" error). I really want to start working with CSS Modules, but nothing I try seems to work for me at all. 😞 |
Hey fellas, I managed to get this working with SASS. Perhaps it's not the best or most elegant solution but here is my gulpfile. Usage in code looks like this: import component1 from './.tmp/css/component1.css';
import component2 from './.tmp/css/component2.css';
...component1.someClass... I haven't worked out the |
Interesting, thanks for sharing @LoganBarnett |
@LoganBarnett I had thought of doing something like that, but using temporary directories makes me feel like we're using Grunt again... Part of the reason we use Gulp is to avoid file writes for intermediate steps. Also, just curious, how do you use ES2015 in your Gulp files? |
@joezimjs Agreed re: grunt vs. gulp, but when the alternative is that I can't use a css preprocessor alone, I'll take a grunt-like hack. I'm not familiar enough with gulp's innards nor browserify's to have a clear direction on fixing this. It might also mean that css-modules (or just this plugin) needs to better speak vinyl streams or something. Any insight here would be most welcome! As for ES6 (2015?), I'm just running node with zsh:
Reaching into bash:
|
What about letting user define which extensions should be transformed? It's similar to this in webpack: [
{ test: /\.(sass|scss|css)$/, loader: 'style!css?modules!postcss' },
{ test: /\.sass$/, loader: 'sass?indentedSyntax' },
{ test: /\.scss$/, loader: 'scss' }
] You just need to add option to override RegExp here I think it would be cool if we could set it like this (comma-separated list of extensions): browserify -t babelify -t envify -t <sassify|stylusify|whateverify> -p [ css-modulesify -o all.css --test 'sass,css' ] entry.js And also like this (RegExp): browserify -t babelify -t envify -t <sassify|stylusify|whateverify> -p [ css-modulesify -o all.css --test '/\.(sass|css)$/' ] entry.js I could submit PR if it looks good. |
After digging a bit deeper I think it's not possible for now, because this module adds its transform earlier than others, so there's a need to make transform separate from plugin itself (just a separate file should work) to add it whenever user wants to. |
Any updates here? Will this be a part of 1.0? Currently waiting on this feature. |
👍 on wanting this. It's kind of a big deal not to be able to use something like SASS. It works with webpack and css modules. |
Any update on this? |
We would like to start using css modules as well but at the minute we use bootstrap as the base and less as a preprocessor so we are trying to investigate which is the best way to bring css modules in as well. |
I do some try for less in less-modulesify |
I am curious if anyone knows what would be required in order for this to happen? |
Is there currently a way to use a pre-processor with this? Like Less or SASS? It would seem that the exclusion of all extensions except for
css
would preclude that unless there is another way to transform the less file name to use css after it gets transformed. In webpack you would just chain the loaders to accomplish this.The text was updated successfully, but these errors were encountered: