-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
update readme with fix from #1939 #2114
Changes from 7 commits
80a10bf
d406724
24f3fcd
b3ce3f7
3dc41f0
8eaaad3
1baf645
df67823
32653a0
2b85cfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,7 +207,7 @@ To configure the syntax highlighting in your favorite text editor, head to the [ | |
|
||
## Displaying Lint Output in the Editor | ||
|
||
>Note: this feature is available with `[email protected]` and higher. | ||
>Note: this feature is available with `[email protected]` and higher. | ||
>It also only works with npm 3 or higher. | ||
|
||
Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. | ||
|
@@ -398,15 +398,14 @@ Following this rule often makes CSS preprocessors less useful, as features like | |
First, let’s install the command-line interface for Sass: | ||
|
||
``` | ||
npm install node-sass --save-dev | ||
npm install node-sass-chokidar --save-dev | ||
``` | ||
|
||
Then in `package.json`, add the following lines to `scripts`: | ||
|
||
```diff | ||
"scripts": { | ||
+ "build-css": "node-sass src/ -o src/", | ||
+ "watch-css": "npm run build-css && node-sass src/ -o src/ --watch --recursive", | ||
+ "build-css": "node-sass-chokidar src/ -o src/", | ||
+ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
|
@@ -430,8 +429,8 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c | |
|
||
```diff | ||
"scripts": { | ||
"build-css": "node-sass src/ -o src/", | ||
"watch-css": "npm run build-css && node-sass src/ -o src/ --watch --recursive", | ||
"build-css": "node-sass-chokidar src/ -o src/", | ||
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we build before we start watching? Does the watcher not compile everything when started in watch mode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. without the
that is correct, the watcher does not compile everything when it first starts.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to comment on this, I do like for example how the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kellyrmilligan do you want to open an issue on node-sass-chokidar requesting this change? I will make the change this weekend if you do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you make the files compile when started in watch mode, please add a flag to disable it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelwayman: would it be helpful to include node_modules, like so:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ajs139 we actually recently added a section about that. It gives advice more about importing without relative paths similar to the NODE PATH env variable fix. I always add my src directory as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we hide css compiled files in "npm start"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean the initial terminal output? If so yes you can pass -q to build-css like so: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank to your reply. I mean that I want to use "node-sass-chokidar" but still can import .scss files. In some react apps built with webpack 2 as I did, we need just import .scss files, can run "npm start" in dev mode without compiling new css files. Therefore, can you improve it? example, build an entire css and hide it somewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like @kellyrmilligan said, custom scss loaders are not supported at the moment.
anyways, perhaps you can convince the visionaries working on this to let you open a PR providing an entry point or env variable into the web-pack-config WITHOUT running eject? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelwayman : Thanks. That's exactly I want. P/S: I'm using VS, and config it to hide css files but it should be not the best method (import from a invisible file) |
||
- "start": "react-scripts start", | ||
- "build": "react-scripts build", | ||
+ "start-js": "react-scripts start", | ||
|
@@ -442,27 +441,17 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c | |
} | ||
``` | ||
|
||
Now running `npm start` and `npm run build` also builds Sass files. Note that `node-sass` seems to have an [issue recognizing newly created files on some systems](https://github.com/sass/node-sass/issues/1891) so you might need to restart the watcher when you create a file until it’s resolved. | ||
Now running `npm start` and `npm run build` also builds Sass files. Note that `node-sass-chokidar` seems to have an issue recognizing newly created files on some systems so you might need to restart the watcher when you create a file until it’s resolved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would like to comment though that @Timer thanks for the tag, this is amazing :) If you want to see why node-sass has this problem, read on: You can see here that node-sass only watches files that are there when program first runs. And possibly newly created files IFF they are imported by a file that IS being watched. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, doesn't this contradict:
@kellyrmilligan Can you confirm you still experience the issue with new files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelwayman in testing it seems to not recognize a new file being added for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is a good way to verify it? I am testing on os x sierra. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, thanks @kellyrmilligan It works as expected for me so I need to try and duplicate your setup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, what I did to test it was:
that was all the "testing" I did but it works fine. So yeah, please describe your steps to reproduce and system info in an issue here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized I tried a |
||
|
||
**Performance Note** | ||
**Why `node-sass-chokidar`?** | ||
|
||
`node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. If you are experiencing high CPU usage with node-sass you can alternatively try [node-sass-chokidar](https://www.npmjs.com/package/node-sass-chokidar) which uses a different file-watcher. Usage remains the same, simply replace `node-sass` with `node-sass-chokidar`: | ||
`node-sass` has been reported as having the following issues: | ||
|
||
``` | ||
npm uninstall node-sass --save-dev | ||
npm install node-sass-chokidar --save-dev | ||
``` | ||
- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. | ||
|
||
And in your scripts: | ||
- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939) | ||
|
||
```diff | ||
"scripts": { | ||
- "build-css": "node-sass src/ -o src/", | ||
- "watch-css": "npm run build-css && node-sass src/ -o src/ --watch --recursive" | ||
+ "build-css": "node-sass-chokidar src/ -o src/", | ||
+ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive" | ||
} | ||
``` | ||
`node-sass-chokidar` is used here as it addresses these issues. | ||
|
||
## Adding Images, Fonts, and Files | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace is significant in markdown. Please leave those two spaces in, they are causing the line to break. They were intentional.