npm scripts

minkyungยท2023๋…„ 9์›” 15์ผ
0

๐Ÿ“Ž scripts - npm Docs

Pre & Post Scripts

package.json ํŒŒ์ผ ๋‚ด "scripts" ์„น์…˜์— ์ •์˜๋œ ์–ด๋–ค script์˜ ์ „์ฒ˜๋ฆฌ(pre), ํ›„์ฒ˜๋ฆฌ(post) script๋ฅผ ์ •์˜ํ•˜๋ ค๋ฉด ํ•ด๋‹น script์˜ ์•ž์— 'pre' ํ˜น์€ 'post'๋ฅผ ๋ถ™์—ฌ์„œ "scripts" ์„น์…˜์— ์ •์˜ํ•˜๋ฉด ๋œ๋‹ค.


{
  "scripts": {
    "precompress": "{{ `compress` ๋ช…๋ น ์‹คํ–‰ ์ „์— ์‹คํ–‰๋จ }}",
    "compress": "{{ ํŒŒ์ผ ์••์ถ•์„ ์œ„ํ•œ ๋ช…๋ น }}",
    "postcompress": "{{ compress` ๋ช…๋ น ์‹คํ–‰ ํ›„์— ์‹คํ–‰๋จ }}"
  }
}

Life Cycle Scripts

ํŠน์ •ํ•œ ์ƒํ™ฉ์—์„œ๋งŒ ์‹คํ–‰๋˜๋Š” ์ˆ˜๋ช…์ฃผ๊ธฐ script๋“ค์ด ์žˆ๋‹ค.

  • prepare, prepublish, prepublishOnly, prepack, postpack, dependencies

prepare

: ํŒจํ‚ค์ง€๊ฐ€ packed ๋˜๊ธฐ ์ „์— ์‹คํ–‰๋œ๋‹ค. (npm publish์™€ npm pack์ด ์‹คํ–‰๋˜๋Š” ๋™์•ˆ)

prepublish ํ›„, prepublishOnly ์ „์— ์‹คํ–‰๋œ๋‹ค.

prepublishOnly

: npm publish ์ „์—๋งŒ ์‹คํ–‰๋œ๋‹ค.

prepack

: npm pack, npm publish, git dependency๊ฐ€ ์„ค์น˜๋˜๊ธฐ ์ „์— ์‹คํ–‰๋œ๋‹ค.

profile
ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€