๐Ÿ“ฆ ํŒจํ‚ค์ €

Parcel ์—์„  ํŒจํ‚ค์ €๊ฐ€ ๋‹ค์ˆ˜์˜ ์• ์…‹์„ ํ•˜๋‚˜์˜ ์ตœ์ข… ์ถœ๋ ฅ ๋ฒˆ๋“ค๋กœ ๊ฒฐํ•ฉ์‹œํ‚ต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๋ชจ๋“  ์• ์…‹์ด ์ฒ˜๋ฆฌ๋˜๊ณ , ํ•˜๋‚˜์˜ ๋ฒˆ๋“ค ํŠธ๋ฆฌ๊ฐ€ ๋งŒ๋“ค์–ด ์ง„ ํ›„ ์ฃผ ๊ณผ์ • ์ค‘์— ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํŒจํ‚ค์ €๋Š” ์ถœ๋ ฅ ํŒŒ์ผ ์œ ํ˜•์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋“ฑ๋ก๋˜๊ณ , ํ•ด๋‹น ์ถœ๋ ฅ ํƒ€์ž…์„ ์ƒ์„ฑํ•œ ์• ์…‹์€ ์ตœ์ข… ์ถœ๋ ฅ ํŒŒ์ผ์˜ ์ œํ’ˆํ™”๋ฅผ ์œ„ํ•ด ํŒจํ‚ค์ €๋กœ ๋ณด๋‚ด์ง‘๋‹ˆ๋‹ค.

ํŒจํ‚ค์ € ์ธํ„ฐํŽ˜์ด์Šค

const { Packager } = require('parcel-bundler')

class MyPackager extends Packager {
  async start() {
    // ์˜ต์…˜. ํ•„์š”ํ•˜๋‹ค๋ฉด ํŒŒ์ผ ํ—ค๋” ์ž‘์„ฑ.
    await this.dest.write(header)
  }

  async addAsset(asset) {
    // ํ•„์ˆ˜. ์ถœ๋ ฅ ํŒŒ์ผ์— ์• ์…‹ ์ž‘์„ฑ.
    await this.dest.write(asset.generated.foo)
  }

  async end() {
    // ์˜ต์…˜. ํ•„์š”ํ•˜๋‹ค๋ฉด ํŒŒ์ผ ํŠธ๋ ˆ์ผ๋Ÿฌ ์ž‘์„ฑ.
    await this.dest.end(trailer)
  }
}

ํŒจํ‚ค์ € ๋“ฑ๋กํ•˜๊ธฐ

addPackager ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒˆ๋“ค๋Ÿฌ์— ํŒจํ‚ค์ €๋ฅผ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฉ”์†Œ๋“œ๋Š” ๋“ฑ๋กํ•˜๋ ค๋Š” ํŒŒ์ผ ์œ ํ˜•๊ณผ ํŒจํ‚ค์ € ๋ชจ๋“ˆ์˜ ๊ฒฝ๋กœ๋ฅผ ๋ฐ›์•„๋“ค์ž…๋‹ˆ๋‹ค.

const Bundler = require('parcel-bundler')

let bundler = new Bundler('input.js')
bundler.addPackager('foo', require.resolve('./MyPackager'))

Help us improve the docs

If something is missing or not entirely clear, please file an issue on the website repository or edit this page.