-
-
Notifications
You must be signed in to change notification settings - Fork 27k
How can i use Less with create-react-app #3457
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
Comments
Perhaps it is worth keeping a watch on #2467. It might also be of helpful if you could add the problems or challenges you faced to that ticket. |
You can't use something like less-loader or anything that plugs into webpack without ejecting. There are instructions in the readme for sass that are equally applicable to less, but the gist is that you need to run a separate watch process that compiles your less into css and then import the compiled css. |
This is my package.json configuration: "scripts": { "build-css": "lessc sourcepath/mylessfile.less destinypath/mygeneratedcssfile.css --source-map=destinypath/mygeneratedmapfile.css.map", "watch-less": "less-watch-compiler sourcepath destinypath mylessfile.less --source-map" } Using http://lesscss.org/ and https://github.com/jonycheung/deadsimple-less-watch-compiler. |
Thx your guys. It seems that the issue can be resolved by:
I am also wondering how could ant-design-pro support |
less-watch-compiler has some problem in my project not fix at now:
|
Here is a workaround:
then add these lines to npm scripts:
|
Closing this as answered, simply follow the instructions here but modify them for Less: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc. |
If you would like to use Less with create-react-app v2, there is a new configuration management tool called craco that makes this very easy. It's very similar to react-app-rewired, but it supports CRA v2. I've got everything working with Ant Design, Less, and Preact, and I've put together some example configuration files.
|
I am using this awesome boilerplate to build my own project. I wanna use Less in my project but encountered some problems.
It took me a lot of time to investigate how to combine Less with create-react-app, however I couldn't find the best practice without ejecting the config. I also tried to use less-loader but it seems hard for me to config.
Could you please provide a usage of using Less with create-react-app in best practice? thx.
The text was updated successfully, but these errors were encountered: