LoginSignup
0
1

More than 1 year has passed since last update.

wireitの利用例

Last updated at Posted at 2022-06-10

wireit

wireitは設定だけでscriptsの並列処理ができる事が魅力です。

  "scripts": {
    "vercel": "echo 1",
    "wrangler": "echo 2",
    "firebase_host": "echo 3"
  },

通常、↑の実行は次のように行っています↓

npm run vercel 
npm run wrangler
npm run firebase_host

wireitを利用したnpm script例にするとscript自体は冗長化しますが、
並行実行ができます。

  "scripts": {
    "build": "wireit",
    "vercel": "wireit",
    "wrangler": "wireit",
    "netlify": "wireit",
    "firebase_host": "wireit"
  },
  "wireit": {
    "build": {"command": "ls ", "dependencies":["vercel", "wrangler", "netlify", "firebase_host"]},
    "vercel": {"command": "echo 1"},
    "firebase_host" : {"echo 2"},
    "wrangler": {"command": "echo 3"},
    "netlify": {"command": "ls"}
  }

↑の実行は次↓のように行います。(4並列で動かしてみます)

export WIREIT_PARALLEL=4 
npm run build

パラレル実行ができることは魅力ですね
https://github.com/google/wireit#parallelism

所感

npm scriptsへのwireit適応による嬉しさは、はGulpによりparallel実行がもたらされた時のちょっと嬉しい感覚に似ています。ただ、適応後のコードは少し冗長になるかもしれません。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1