我正在使用 npm 脚本进行测试,以最终消除对 Gulp 的依赖。我只是从一个名为watch
. 该脚本最终将运行所有以该watch
名称开头的脚本;例如watch:styles
。我的watch:styles
脚本将使用 node-sass 将我的 sass 文件编译成 CSS。这行得通。但是,我的下一步是创建一个postwatch:styles
脚本,.css
通过 PostCSS 和 Autoprefixer 运行新创建的文件。
但是,问题是我的postwatch:styles
钩子永远不会被触发运行。
包.json
{
"name": "npm-scripts-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"watch": "npm-run-all --parallel watch:*",
"watch:styles": "node-sass -w ./src/styles/main.scss ./dist/assets/styles/app.css",
"postwatch:styles": "postcss -u autoprefixer --no-map ./dist/assets/styles/app.css -o ./dist/assets/styles/app.css"
},
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"autoprefixer": "^7.1.1",
"node-sass": "^4.5.3",
"postcss-cli": "^4.0.0",
"yarn-run-all": "^3.1.1"
},
"browserslist": [
"last 3 versions"
]
}
关于为什么我的帖子挂钩没有触发的任何建议或建议?初始watch:styles
运行良好。如果我yarn postwatch:styles
手动运行脚本运行正确。会不会有一个静默错误watch:styles
阻止钩子触发?
任何建议将不胜感激。