yarnでやっていこうと思います。
プロジェクトの新規作成
> yarn init
parcelJSを入れる
> yarn add parcel-bundler --dev
package.jsonの編集
package.jsonに以下を追加する。
Laravel想定。あとindex.jsをコンパイルする想定。
"scripts": {
"dev": "parcel ./resources/js/index.js -d ./public/js/",
"build": "parcel build ./resources/js/index.js -d ./public/js/"
},
なお、上記スクリプトは実行するとparcelJSが準備している開発サーバが立ち上がるので、
それを行いたくない場合は以下のスクリプトを利用する。
"scripts": {
"dev": "parcel watch ./resources/js/index.js -d ./public/js/",
"build": "parcel build ./resources/js/index.js -d ./public/js/"
},
実行
yarn dev
これで、コンパイルされたindex.jsが/public/js/
配下に出力されます。