[npm & Bower] Sass と PostCSS の処理を && で繋げると発生するエラーを npm-run-all で解決する
Sass のコンパイル後 PostCSS 処理する npm script。
npm-run-all で解決できました。
[markdown]
## 症状
このような形式で `&&` するとエラーが発生。
“`prettyprinted:package.json
“scripts”: {
“build”: “yarn run scss && yarn run autoprefixer && yarn run csswring”,
“scss”: “node-sass –source-map-embed -o $npm_package_config_css_dir $npm_package_config_sass_dir”,
“autoprefixer”: “postcss -u autoprefixer -r $npm_package_config_css_dir/**/*.css”,
“csswring”: “postcss –no-map -u csswring -r $npm_package_config_css_dir/**/*.css”,
“`
エラー。
postcss-cli の仕様が絡んでいるようで困惑。
gulp は使いたくない。
“`prettyprinted
✖ Input Error: Did not receive any STDIN
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
“`
## 対応
インストール。
“`prettyprinted
% yarn add npm-run-all –dev
“`
> * [mysticatea/npm-run-all: A CLI tool to run multiple npm-scripts in parallel or sequential.](https://github.com/mysticatea/npm-run-all)
CLI コマンドを書き換えます。
“`prettyprinted:package.json
“scripts”: {
“build”: “npm-run-all scss autoprefixer csswring”
“`
npm scripter 御用達。
## 補遺
> * [npm-run-all と concurrently を試す – アカベコマイリ](http://akabeko.me/blog/2015/08/npm-run-all-and-concurrently/)
> * [npm-run-all v1.2.8 を試す – アカベコマイリ](http://akabeko.me/blog/2015/09/npm-run-all-v1-2-8/)
> * [[WIP] npm-scripts を使い倒そう! – Qiita](http://qiita.com/mysticatea/items/e9bf581fb28c5f1cd660)
> * [npm-scripts で Web フロントエンド開発を管理する – アカベコマイリ](http://akabeko.me/blog/2016/10/npm-scripts-web-front-end-development/)
[/markdown]