最終的に Gulp への依存を取り除くために、npm スクリプトを使用してテストしています。という 1 つのメイン カスタム スクリプトから簡単に始めています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
フックの発火を妨げているサイレントエラーが発生する可能性はありますか?
どんなアドバイスでも大歓迎です。