Javascript NPM脚本后钩子未触发
我正在使用npm脚本进行测试,以最终消除对Gulp的依赖。我只是从一个名为Javascript NPM脚本后钩子未触发,javascript,node.js,npm,postcss,npm-scripts,Javascript,Node.js,Npm,Postcss,Npm Scripts,我正在使用npm脚本进行测试,以最终消除对Gulp的依赖。我只是从一个名为watch的主要自定义脚本开始。此脚本最终将运行所有以watch名称开头的脚本;例如watch:styles。我的watch:styles脚本将使用节点sass将我的sass文件编译成CSS。这很有效。但是,我的下一步是创建一个postwatch:styles脚本,通过postss和Autoprefixer运行新创建的.css文件 问题在于我的postwatch:styleshook从未被触发运行 package.json
watch
的主要自定义脚本开始。此脚本最终将运行所有以watch
名称开头的脚本;例如watch:styles
。我的watch:styles
脚本将使用节点sass将我的sass文件编译成CSS。这很有效。但是,我的下一步是创建一个postwatch:styles
脚本,通过postss和Autoprefixer运行新创建的.css
文件
问题在于我的postwatch:styles
hook从未被触发运行
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
运行正常。如果手动运行warn postwatch:styles
,脚本将正确运行。我的watch:styles
会不会有一个无声的错误阻止钩子开火
任何建议都将不胜感激。由于
watch:styles
在watch模式下调用node sass
,因此该命令不会返回,而是处于活动状态,等待文件更改
由于没有正面回报,postwatch:styles
将永远不会被调用
您应该尝试另一种方法,或者
nodemon
因为watch:styles
在watch模式下调用node sass
,该命令永远不会返回,而是处于活动状态,等待您的文件更改
由于没有正面回报,postwatch:styles
将永远不会被调用
您应该尝试另一种方法,或者是非常有意义的
nodemon
。非常感谢。这很有道理。非常感谢。