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
create-react-app如何使用less/sass和react-css-modules? #61
Comments
1.create-react-app如何使用less?安装less-watch-compiler到开发依赖。
添加scripts
运行命令
运行结果
程序运行起来后,会监控对应目录下的.less文件,热更新到css目录下。 |
2.create-react-app如何使用sass?安装node-sass-chokidar到依赖
添加scripts
运行命令
运行结果
程序运行起来后,会监控对应目录下的.scss文件,热更新到css目录下。 |
3.create-react-app如何使用react-css-modules?暴露出配置文件:
运行eject命令后,CRA会自动把wepack中与css-modules相关的依赖为我们准备好,无需新增多余的依赖。 修改config/webpack.config.dev.js:
修改config/webpack.config.prod.js:
代码变化:
引入CSS Modules之后:
添加css-modules之前:
添加css-modules之后:
运行结果
注意事项:
参考:https://medium.com/nulogy/how-to-use-css-modules-with-create-react-app-9e44bec2b5c2 |
Thanks @pengzeya
The text was updated successfully, but these errors were encountered: