Skip to content

Commit 67d0d49

Browse files
authored
Document Sass imports
1 parent 92a0680 commit 67d0d49

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/react-scripts/template/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ Then in `package.json`, add the following lines to `scripts`:
406406
407407
Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated.
408408

409+
To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions.
410+
409411
At this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control.
410412

411413
As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this:

0 commit comments

Comments
 (0)