【发布时间】:2017-11-03 02:58:00
【问题描述】:
我正在使用 npm 脚本进行测试,以最终消除对 Gulp 的依赖。我只是从一个名为watch 的主要自定义脚本开始。该脚本最终将运行所有以watch 名称开头的脚本;例如watch:styles。我的watch:styles 脚本将使用 node-sass 将我的 sass 文件编译成 CSS。这行得通。但是,我的下一步是创建一个 postwatch:styles 脚本,该脚本通过 PostCSS 和 Autoprefixer 运行新创建的 .css 文件。
问题是我的 postwatch:styles 钩子永远不会被触发运行。
package.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 上是否存在阻止钩子触发的静默错误?
任何建议将不胜感激。
【问题讨论】:
标签: javascript node.js npm postcss npm-scripts