At the beginning, I added sASS syntax support by referring to the official website document, adding shingle-a-CSS-preprocessor-sass-less-etc for a long time. However, the program did not perform as expected. Although the changes could be monitored, the page style was not applied.
Project Code:
page
The style file
component
The style of the login button is not applied.
He decided to take matters into his own hands
The first step:
Unseal NPM run eject
After executing it, you’ll get a bunch of files. Find the webpack.config.dev.js file in the config folder
Add the following code:
The second step:
NPM install –save-dev sass-loader node-sass
After completing the previous two steps, run NPM run start
However, don’t feel like you’re done here. Find the webpack.config.prod.js file in config and do the same.
After making the changes, run NPM run build to check that the packaging is correct. In the build/static/CSS/main. XXX. CSS search, whether to have our writing style.
Support for adding sass syntax to create-react-app is now complete.