Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

compile ok, but --watch mode not work. #2300

Closed
GongT opened this issue Mar 22, 2018 · 3 comments
Closed

compile ok, but --watch mode not work. #2300

GongT opened this issue Mar 22, 2018 · 3 comments

Comments

@GongT
Copy link

GongT commented Mar 22, 2018

  • NPM version (npm -v): 5.7.1
  • Node version (node -v): v9.4.0
  • Node Process (node -p process.versions):
{ http_parser: '2.7.0',
  node: '9.4.0',
  v8: '6.2.414.46-node.17',
  uv: '1.18.0',
  zlib: '1.2.11',
  ares: '1.13.0',
  modules: '59',
  nghttp2: '1.29.0',
  openssl: '1.0.2n',
  icu: '60.1',
  unicode: '10.0',
  cldr: '32.0',
  tz: '2017c' }
  • Node Platform (node -p process.platform): linux
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"):

node-sass 4.7.2 (Wrapper) [JavaScript]
libsass 3.5.0.beta.2 (Sass Compiler) [C/C++]

  • npm node-sass versions (npm ls node-sass):

universal-meme@1.0.0 /data/DevelopmentRoot/projects/universal-meme
└── node-sass@4.7.2

  • which node-sass: ./node_modules/.bin/node-sass

  • successed log:
    node-sass --output dist/css styles/index.scss
    Rendering Complete, saving .css file...
    Wrote CSS to /data/DevelopmentRoot/projects/universal-meme/dist/css/index.css

  • failed log:
    node-sass --output dist/css styles/index.scss -w
    <-- hang there, no file generated.

 // styles/index.scss
body, html {
	padding: 0;
	margin: 0;
	width: 100%;
	height: 100%;
}
@francoismassart
Copy link

francoismassart commented Mar 23, 2018

@GongT I believe watch requires a change in your source files to be triggered...

Once the node-sass ... -w has been launched, try to save your index.scss file and it should compile it.

If you use npm scripts inside your package.json file, and if you do not want to have to save/change your file to compile them at launch you can simply use a pre script or &&...

Let's see an example using a pre script:

  "scripts": {
     "css-compile": "node-sass --output dist/css styles/index.scss",
     "precss-watch": "npm run css-compile",
     "css-watch": "npm run css-compile -- -w"
  }

In this first example running npm run css-watch will:

  • first execute the script precss-watch which run the "basic" compilation with your default params.
  • then run the same "basic" command invoked from css-watch with an additional param: -w

I prefer using pre scripts when possible but can also use && which run another script once the preceding is done:

Let's see an example using &&:

  "scripts": {
     "css-compile": "node-sass --output dist/css styles/index.scss",
     "css-watch": "npm run css-compile && npm run css-compile -- -w"
  }

Let me know if it helps and close the issue if you are satisfied.

@GongT
Copy link
Author

GongT commented Mar 28, 2018

I not even try to modify any file, LOL...

@GongT GongT closed this as completed Mar 28, 2018
@ccarter13
Copy link

I ran into the same issue, just go to View-Extensions- and download the “Live Sass Compiler”. This will automatically watch your sass code and create a main.css file without you having to manually run it in the terminal.

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

No branches or pull requests

3 participants