2016-05-16 40 views
2

我是npm newbee,並試圖用純npm(沒有咕嚕咕嚕,吞嚥等)有一個非常簡單的構建過程。我所有的包json腳本都能正常工作,可以讓負責觀察SCSS文件的人以及在文件更改時運行編譯器。
這裏是我的package.json文件,這應該是自我解釋:npm插件「onchange」不能識別scss文件的變化

{ 
     "name": "test-site.com", 
     "version": "1.0.0", 
     "description": "", 
     "main": "index.js", 
     "scripts": { 
     "scss": "node-sass --indent-type tab --indent-width 1 --output-style expanded -o dist/css src/scss", 
     "autoprefixer": "postcss -u autoprefixer -r dist/css/app.css", 
     "build:css": "npm run scss && npm run autoprefixer", 
     "serve": "browser-sync start --server --files 'dist/css/*.css, **/*.html, !node_modules/**/*.html'", 
     "reload": "browser-sync reload", 
     "watch:css": "onchange 'src/scss/*.scss' -- npm run build:scss", 
     "build:all": "npm run build:css", 
     "watch:all": "npm-run-all -p serve watch:css", 
     "postinstall": "npm run build:all && npm run watch:all" 
     }, 
     "author": "Homam", 
     "license": "ISC", 
     "devDependencies": { 
     "autoprefixer": "latest", 
     "browser-sync": "latest", 
     "node-sass": "latest", 
     "npm-run-all": "latest", 
     "onchange": "latest", 
     "postcss-cli": "latest" 
     } 
    } 

有問題的腳本是「手錶:CSS」。
當我更改我的「index.html」時,它會相應更改網頁,但在更改我的任何SCSS文件時沒有更改效果。

回答

3

可能是因爲

"watch:css": "onchange 'src/scss/*.scss' -- npm run build:scss", 

所引用的構建:SCSS未被定義?你已經定義了「scss」和「build:css」。試一下:

"watch:css": "onchange 'src/scss/*.scss' -- npm run build:css", 
6

你在Windows上嗎? 如果是這樣,請嘗試用onchange README中所述的單引號替換轉義雙引號。

"watch:css": "onchange \"src/scss/*.scss\" -- npm run build:scss", 
+0

感謝的人...

+0

這有助於解釋爲什麼我的守望者是在Windows「掛」,謝謝! –