Skip to content
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

Browser Sync cli non-stop file changed when used with postcss-cli watch #772

Closed
nelsyeung opened this issue Aug 16, 2015 · 1 comment
Closed

Comments

@nelsyeung
Copy link

I'm not really sure whether this is a browser-sync problem or postcss-cli, but when the two work together there will be non-stop file changed on the css file.

package.json

{
  "name": "test",
  "scripts": {
    "postcss": "postcss --use autoprefixer main.css -o main.css -w",
    "browser-sync": "browser-sync start --server --files 'index.html, main.css'",
    "start": "parallelshell 'npm run postcss' 'npm run browser-sync'"
  },
  "devDependencies": {
    "autoprefixer": "^5.2.0",
    "browser-sync": "^2.8.2",
    "parallelshell": "^2.0.0",
    "postcss-cli": "^1.5.0"
  }
}

Simply run npm start and you will get non-stop file changed on main.css.

screen shot 2015-08-16 at 17 34 47

Some notes:

  • Using other watch packages will not cause this problem. However, using watch with postcss will cause the problem.
  • index.html and main.css don't require to have any contents.
  • OS: Mac OS 10.10 (Yosemite)
@shakyShane
Copy link
Contributor

You have an error in your setup - you don't want to watch and compile to the same CSS file. You should have a source CSS file & a resulting CSS file (that you link to in your HTML page).

Change to something like

{
  "name": "test",
  "scripts": {
    "postcss": "postcss --use autoprefixer main.css -o main-dist.css -w",
    "browser-sync": "browser-sync start --server --files 'index.html, main-dist.css'",
    "start": "parallelshell 'npm run postcss' 'npm run browser-sync'"
  },
  "devDependencies": {
    "autoprefixer": "^5.2.0",
    "browser-sync": "^2.8.2",
    "parallelshell": "^2.0.0",
    "postcss-cli": "^1.5.0"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants