我正在尝试将SCSS-lint设置到Angular 2项目上,虽然我可以让它在npm start上运行,如果我手动运行我的命令,我无法弄清楚如何让它在我运行时运行保存文件。
"scripts": {
"ng": "ng",
"start": "npm run scss-lint && ng serve --host $npm_package_config_host --port $npm_package_config_port --ec=true",
"start-live-data": "ng serve --host $npm_package_config_host --port $npm_package_config_port --environment=livedata --ec=true --aot",
"start-prod": "npm run build-prod && npm run pm2:restart-prod || npm run pm2:start-prod",
"start-prod-v2": "npm run build-prod && npm run pm2:restart-prod-v2 || npm run pm2:start-prod-v2",
"build": "ng build --aot",
"prebuild-prod": "npm install",
"build-prod": "ng build --environment=production --aot",
"test": "ng test -sm=false --code-coverage --single-run",
"test-watch": "ng test --code-coverage",
"test-debug": "ng test --browsers ChromeDebug",
"lint": "ng lint",
"scss-lint": "sass-lint 'src/**/*.scss' -v -q",
"e2e": "ng e2e",
"pm2:restart-prod": "NODE_ENV=production pm2 restart audience-dashboard-client",
"pm2:start-prod": "NODE_ENV=production pm2 start -i max --name audience-dashboard-client node -- server.js",
"pm2:restart-prod-v2": "NODE_ENV=production PORT=8085 pm2 restart audience-client-2",
"pm2:start-prod-v2": "NODE_ENV=production PORT=8085 pm2 start --name audience-client-2 node -- server.js"
}
npm运行scss-lint 上面的命令是我想在保存SCSS文件时运行的命令。
之前有没有人遇到过这个问题?
******更新******
手表似乎是通过ng服务发生的,是否可以添加到此命令?
答案 0 :(得分:0)
你可以试试这个。首先安装“手表”包:
npm install watch
然后在你的package.json中添加你的脚本:
"scss:compiler": "./node_modules/.bin/watch \"sass-lint 'src/**/*.scss' -v -q\" src"
src应该是您要监视更改的文件夹的名称。