Skip to content

Commit

Permalink
update CSS preprocessor instructions (facebook#1543)
Browse files Browse the repository at this point in the history
* update CSS preprocessor instructions
- Windows shell users should note that running two programs simultaneously is not supported.

* fix the order of SASS build step
- the suggested build step with integrated CSS preprocessing is wrong. The SASS preprocessor should run first, then the react-scripts build will pick the up-to-date final CSS

* Add tweaks from PR discussion
  • Loading branch information
Alessandro Burato authored and randycoulman committed May 8, 2017
1 parent 6a343db commit a0fc95e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,23 @@ Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`.

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.

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 `&` operator for executing scripts in parallel, and `&&` for executing them sequentially:
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:

```
npm install --save-dev npm-run-all
```

Then we can change `start` and `build` scripts to include the CSS preprocessor commands:

```diff
"scripts": {
"build-css": "node-sass src/ -o src/",
"watch-css": "npm run build-css && node-sass src/ -o src/ --watch",
- "start": "react-scripts start",
- "build": "react-scripts build",
+ "start": "react-scripts start & npm run watch-css",
+ "build": "react-scripts build && npm run build-css",
+ "start-js": "react-scripts start",
+ "start": "npm-run-all -p watch-css start-js",
+ "build": "npm run build-css && react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
Expand Down

0 comments on commit a0fc95e

Please sign in to comment.