๐Ÿ”จ ๋ฒˆ๋“ค๋Ÿฌ(Bundler) ๊ธฐ์ดˆ(๋ชจ๋“ˆ, parcel, webpack)

Lee Jooamยท2022๋…„ 5์›” 3์ผ
0
post-thumbnail
post-custom-banner

๐ŸŒŽ ๋ฐฐ๊ฒฝ

๋ฒˆ๋“ค๋Ÿฌ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•˜๊ธฐ ์ด์ „์— ๋ฒˆ๋“ค๋Ÿฌ๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋œ ๋ฐฐ๊ฒฝ์— ๋Œ€ํ•ด ์•Œ๊ณ  ๊ณต๊ฐํ•ด์•ผ ํ•œ๋‹ค.

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ์›น ํŽ˜์ด์ง€๋ฅผ ์ œ์–ดํ•˜๋Š” ์šฉ๋„๋กœ ์‚ฌ์šฉ๋๊ณ , ๋˜ํ•œ ์˜›๋‚ ์˜ ์›น ํŽ˜์ด์ง€๋Š” ๋ณต์žกํ•œ ๊ธฐ๋Šฅ์ด ๋ณ„๋กœ ์—†์—ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ํ•˜๋‚˜์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ๋กœ๋„ ๋ชจ๋“  ์ž์›์„ ๊ด€๋ฆฌํ•ด๋„ ๊ดœ์ฐฎ์•˜๋‹ค.

ํ•˜์ง€๋งŒ ์›น์ด ์ ์  ๋ณต์žกํ•ด์ง€๊ณ  ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋„ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•˜๋ฉด์„œ ๋‹จ์ˆœํžˆ ์›น์„ ์ œ์–ดํ•˜๋Š” ์—ญํ• ๋กœ๋งŒ ์“ฐ์ด์ง€ ์•Š๋Š”๋‹ค.

์ด๋Ÿฐ ์ƒํ™ฉ ์†์—์„œ ํ•˜๋‚˜์˜ JS ํŒŒ์ผ๋กœ ๋ชจ๋“  ์ž์›๋“ค์„ ๊ด€๋ฆฌํ•˜๊ธฐ๋ž€ ๊ต‰์žฅํžˆ ๋ณต์žกํ•˜๊ณ  ์–ด๋ ค์› ๊ธฐ ๋•Œ๋ฌธ์— ์ƒˆ๋กœ์šด ๊ธฐ์ˆ ์ด ์ถœํ˜„ํ•œ๋‹ค. ๋ฐ”๋กœ ๋ชจ๋“ˆ ์‹œ์Šคํ…œ์ด๋‹ค.

โœ” ๋ชจ๋“ˆ

ํ•˜๋‚˜์˜ JS ํŒŒ์ผ์„ ๋ถ„๋ฆฌํ•˜๊ณ  ๊ฐ๊ฐ์˜ ํŒŒ์ผ๋“ค์„ ๋ชจ๋“ˆ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. Node ํ™˜๊ฒฝ์—์„œ๋Š” ์ฃผ๋กœ common js, ๋ธŒ๋ผ์šฐ์ € ํ™˜๊ฒฝ์—์„œ๋Š” ES2015 ์ดํ›„๋กœ ESM์„ ์ง€์›ํ•œ๋‹ค.

ESM์€ ์šฐ๋ฆฌ๊ฐ€ ์ž˜ ์•Œ๊ณ  ์žˆ๋Š” import, export ํ‚ค์›Œ๋“œ๋ฅผ ์ด์šฉํ•œ ๋ฐฉ๋ฒ•์ด๋‹ค.

import { user } from './user.js';

const username = user.name;

ESM์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋ธŒ๋ผ์šฐ์ €์—๊ฒŒ ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์ด ๋ชจ๋“ˆ์ด๋ผ๋Š” ๊ฒƒ์„ ์•Œ๋ ค์ฃผ์–ด์•ผ ํ•œ๋‹ค.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/style.css" />
    <script type="module" src="./js/edit.js"></script>
    <script type="module" src="./js/main.js"></script>
    <title>Document</title>
  </head>
  <body>
    <h1>Hello</h1>
  </body>
</html>

๋‹ค์Œ๊ณผ ๊ฐ™์ด script ํƒœ๊ทธ์— type์„ module์ด๋ผ๊ณ  ๋ช…์‹œํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ์ฐธ๊ณ ๋กœ ๋ชจ๋“ˆ์€ ํ•ญ์ƒ ์‹คํ–‰์ด ์ง€์—ฐ๋œ๋‹ค.(defer ์†์„ฑ ์ฒ˜๋Ÿผ)

๋ชจ๋“ˆ์„ ์ด์šฉํ•  ๋• ์•ฝ๊ฐ„์˜ ์ฃผ์˜์‚ฌํ•ญ์ด ์žˆ๋Š”๋ฐ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

// user.js
class User {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  sayHi = () => {
    console.log(
      "Hello my name is " + this.name + " I'm " + this.age + " years old."
    );
  };
}

export default new User("Lee", 27);
// edit.js
import User from "./user.js";

console.log(User);

User.name = "Joo";

console.log("User is edited!!");
// main.js
import User from "./user.js";

console.log(User);
User.sayHi();

์ƒ๋‹จ์˜ html ํŒŒ์ผ์— ๋ช…์‹œ๋œ ๋ชจ๋“ˆ์ด ๋‹ค์Œ๊ณผ ๊ฐ™์€ JS ํŒŒ์ผ๋“ค์„ ์‹คํ–‰ํ•œ๋‹ค๊ณ  ํ•ด๋ณด์ž. ์–ด๋–ค ๊ฒฐ๊ณผ๊ฐ€ ์ถœ๋ ฅ๋ ๊นŒ?

main์—์„œ importํ•œ User์˜ ์†์„ฑ์ด ๋ณ€ํ–ˆ๋‹ค. ์ด๋Š” ๋ชจ๋“ˆ์˜ ํŠน์„ฑ ๋•Œ๋ฌธ์ธ๋ฐ, ๋ชจ๋“ˆ์€ ์ตœ์ดˆ ํ˜ธ์ถœ ์‹œ ๋‹จ ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰๋œ๋‹ค.

์ด ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ ๋ชจ๋“ˆ์—์„œ importํ•œ ์ž์›์ด ์ˆ˜์ •๋˜๋ฉด ๊ฐ™์€ ์ž์›์„ importํ•œ ๋ชจ๋“ˆ๋„ ๊ทธ ์˜ํ–ฅ์„ ๋ฐ›๋Š”๋‹ค.

๋˜ํ•œ ๋ชจ๋“ˆ์€ ์ž๊ธฐ ์ž์‹ ๋งŒ์˜ ์Šค์ฝ”ํ”„๊ฐ€ ์žˆ์–ด exportํ•˜์ง€ ์•Š๋Š” ์ด์ƒ ๋‹ค๋ฅธ ๋ชจ๋“ˆ์—์„œ ๋‚ด๋ถ€ ์Šค์ฝ”ํ”„์˜ ๋ณ€์ˆ˜์— ์ ‘๊ทผํ•  ์ˆ˜ ์—†๋‹ค.

๋ฒˆ๋“ค๋Ÿฌ์˜ ์—ญํ• 

์ตœ์‹  ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ ํŒŒ์ผ์„ ๋ชจ๋“ˆ๋กœ ๋‚˜๋ˆ„์–ด ๊ฐœ๋ฐœํ•œ๋‹ค๋Š” ๊ฒƒ์€ ์•Œ์•˜๋‹ค. ํ•˜์ง€๋งŒ ๋ชจ๋“ˆ์˜ ์žฅ์ ๊ณผ ๋ฒˆ๋“ค๋Ÿฌ๊ฐ€ ์–ด๋–ค ์—ฐ๊ด€์ด ์žˆ์„๊นŒ?

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/style.css" />
    <script type="module" src="./js/edit1.js"></script>
    <script type="module" src="./js/edit2.js"></script>
    <script type="module" src="./js/edit3.js"></script>
    <script type="module" src="./js/edit4.js"></script>
    <script type="module" src="./js/edit5.js"></script>
    <script type="module" src="./js/edit6.js"></script>
    <script type="module" src="./js/edit7.js"></script>
    <script type="module" src="./js/edit8.js"></script>
    <script type="module" src="./js/edit9.js"></script>
    <script type="module" src="./js/edit10.js"></script>
    <script type="module" src="./js/main.js"></script>
    <title>Document</title>
  </head>
  <body>
    <h1>Hello</h1>
  </body>
</html>

๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ์˜ ์›น ์•ฑ์ด ์žˆ๋‹ค.

ํŽธ์˜์ƒ edit์— ์ธ๋ฑ์‹ฑ์„ ํ–ˆ์ง€๋งŒ ๊ฐ๊ฐ์„ ๋ชจ๋‘ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ํ†ตํ•ด ๋ฐ›์•„์ง€๋Š” ๊ฐ๊ธฐ ๋‹ค๋ฅธ ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์ด๋ผ๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž.

10๊ฐœ ์ •๋„ ์ฏค์ด์•ผ ์ปค๋‹ค๋ž€ ๋”œ๋ ˆ์ด๊ฐ€ ์ƒ๊ธฐ์ง€ ์•Š๊ฒ ์ง€๋งŒ ํŒŒ์ผ์ด ์ˆ˜๋ฐฑ ๊ฐœ๋ผ๋ฉด ์–ด๋–จ๊นŒ? ์ˆ˜๋ฐฑ ๋ฒˆ์˜ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์€ ์•„๋ฌด๋ฆฌ ์ƒ๊ฐํ•ด๋„ ๋น„ํšจ์œจ์ ์ผ ๊ฒƒ ๊ฐ™๋‹ค.

๋ฒˆ๋“ค๋Ÿฌ๋Š” ์ด๋Ÿฌํ•œ ํ˜•ํƒœ๋กœ ๊ตฌ์„ฑ๋œ JS ํŒŒ์ผ๋“ค์„ ํ•˜๋‚˜๋กœ ๋ฌถ์–ด์ค„ ์ˆ˜ ์žˆ๋‹ค.

!function(){"use strict";var n,e,t,r,o,a,i,c,s,u,f,l,p,d,v={705:function(n){n.exports=function(n){var e=[];return e.toString=function(){return this.map((function(e){var t="",r=void 0!==e[5];return e[4]&&(t+="@supports (".concat(e[4],") {")),e[2]&&(t+="@media ".concat(e[2]," {")),r&&(t+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),t+=n(e),r&&(t+="}"),e[2]&&(t+="}"),e[4]&&(t+="}"),t})).jo...

๋˜ํ•œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ๋‚œ๋…ํ™” ํ•˜๋Š”๋ฐ, ๊ฐœ๋ฐœ์ž์˜ ํŽธ์˜์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•œ ์ค„๋ฐ”๊ฟˆ์ด๋‚˜ ๋“ค์—ฌ์“ฐ๊ธฐ ๋“ฑ์„ ๋ชจ๋‘ ์—†์• ๊ณ  ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ํ•ด๋…๋งŒ ๊ฐ€๋Šฅํ•  ์ •๋„์˜ ํŒŒ์ผ๋กœ ์••์ถ•ํ•œ๋‹ค.

์ด๋Ÿฐ ํšจ์œจ ์ฆ๋Œ€ ์ด์™ธ์—๋„ babel์„ ํ†ตํ•œ ๋ฌธ๋ฒ•๋ณ€ํ™˜, postCSS๋ฅผ ์ด์šฉํ•œ autoprefixer ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.

Parcel

parcel์€ ๋ฒˆ๋“ค๋Ÿฌ์˜ ํ•œ ์ข…๋ฅ˜์ด๋‹ค. parcel์˜ ์žฅ์ ์€ ๊ฐ€๋ณ๋‹ค๋Š” ๊ฒƒ์„ ๊ผฝ์„ ์ˆ˜ ์žˆ๋‹ค.

zero-configuration(config ํŒŒ์ผ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Œ)์ด๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ž์˜ ์ž…์žฅ์—์„œ๋Š” ์กฐ๊ธˆ ๋” ์‰ฝ๊ฒŒ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.

์„ค์น˜

yarn add parcel-bundler

ํ”„๋กœ์ ํŠธ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๊ทธ๊ฒƒ์œผ๋กœ ์„ค์น˜๋Š” ๋์ด๋‹ค.

๊ฐ„๋‹จํ•œ ํ”„๋กœ์ ํŠธ๋ผ๋ฉด ์ดํ›„์— ๋ฐ”๋กœ ๋ฒˆ๋“ค๋ง ๋ช…๋ น์„ ์ง„ํ–‰ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

์ถ”๊ฐ€๊ธฐ๋Šฅ

autoprefixer๋‚˜ babel ๋“ฑ์„ ์ด์šฉํ•˜๋ ค๋ฉด ์ถ”๊ฐ€ ํŒจํ‚ค์ง€๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•œ package.jsonํŒŒ์ผ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

{
  "name": "part8_parcel",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@babel/core": "^7.17.10",
    "@babel/plugin-transform-runtime": "^7.17.10",
    "@babel/preset-env": "^7.17.10",
    "autoprefixer": "9",
    "parcel-bundler": "^1.12.5",
    "parcel-plugin-static-files-copy": "^2.6.0",
    "postcss": "^8.4.13"
  },
  "scripts": {
    "start": "parcel index.html"
  },
  "staticFiles": {
    "staticPath": "statics"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

parcel-plugin-static-files-copy๋Š” staticํ•œ ํŒŒ์ผ๋“ค์„ ๋นŒ๋“œ ๊ฒฐ๊ณผ์— copyํ•ด์ฃผ๋Š” ํŒจํ‚ค์ง€, @babel/preset-env ๋ฐ”๋ฒจ ์ปดํŒŒ์ผ์— ํ•„์š”ํ•œ ํ”Œ๋Ÿฌ๊ทธ์ธ ๊ทธ๋ฃน, @babel/plugin-transform-runtime๋Š” ์ถ”๊ฐ€ ํ”Œ๋Ÿฌ๊ทธ์ธ์ธ๋‹ค.

browserslist๋Š” autoprefixer๋‚˜ babel์—๊ฒŒ ์ง€์›ํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ €์˜ ๋ฒ”์œ„๋ฅผ ์•Œ๋ ค์ค€๋‹ค.

ํ•ด๋‹น json์—์„œ๋Š” ์ „์„ธ๊ณ„ ์ ์œ ์œจ 1% ์ด์ƒ์ธ ๋ธŒ๋ผ์šฐ์ €์˜ ๋งˆ์ง€๋ง‰ 2 ๋ฒ„์ „๊นŒ์ง€ ์ง€์›ํ•˜๋ผ๊ณ  ๋ช…์‹œํ•˜๊ณ  ์žˆ๋‹ค.

// .babelrc.js
module.exports = {
  presets: ["@babel/preset-env"],
  plugins: [["@babel/plugin-transform-runtime"]],
};
// .postcssrc.js
module.exports = {
  plugins: [require("autoprefixer")],
};

parcel์€ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” babel์ด๋‚˜ postCSS ๋“ฑ์˜ ํŠธ๋žœ์ŠคํŒŒ์ผ๋Ÿฌ๋“ค์„ ๋‚ด์žฅ ์ง€์›ํ•˜๋Š”๋ฐ ์œ„์™€ ๊ฐ™์€ ํŒŒ์ผ์ด ๋ชจ๋“ˆ ๋‚ด๋ถ€์— ์กด์žฌํ•œ๋‹ค๋ฉด ๋ฒˆ๋“ค๋ง ์‹œ ์ž๋™ ๋ณ€ํ™˜ํ•ด์ค€๋‹ค.

Webpack

์›นํŒฉ์€ parcel๋ณด๋‹ค ์‚ฌ์šฉ์ด ์กฐ๊ธˆ ๋” ๊นŒ๋‹ค๋กญ๋‹ค. parcel์ด zero-confiuration์ด์—ˆ๋‹ค๋ฉด webpack์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ config๋ฅผ ์„ค์ •ํ•ด์•ผํ•œ๋‹ค.

๋ณต์žกํ•˜์ง€๋งŒ ๊ทธ๋ ‡๊ฒŒ ํ•จ์œผ๋กœ์จ ํ”„๋กœ์ ํŠธ๋ฅผ ๋นŒ๋“œํ•  ๋•Œ ์„ธ์„ธํ•œ ๋ถ€๋ถ„์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

parcel๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํŒจํ‚ค์ง€๋“ค์„ ์„ค์น˜ํ•ด์•ผ ํ•˜๋ฉฐ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

{
  "name": "part8",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "dev": "webpack-dev-server --mode development",
    "build": "webpack --mode production"
  },
  "license": "MIT",
  "devDependencies": {
    "autoprefixer": "^10.4.7",
    "babel-loader": "^8.2.5",
    "copy-webpack-plugin": "^10.2.4",
    "css-loader": "^6.7.1",
    "html-webpack-plugin": "^5.5.0",
    "postcss": "^8.4.13",
    "postcss-loader": "^6.2.1",
    "style-loader": "^3.3.1",
    "webpack": "^5.72.0",
    "webpack-cli": "^4.9.2",
    "webpack-dev-server": "^4.0.0-rc.1",
    "@babel/core": "^7.17.10",
    "@babel/plugin-transform-runtime": "^7.17.10",
    "@babel/preset-env": "^7.17.10"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ],
}

๋น„์Šทํ•˜์ง€๋งŒ ์•ฝ๊ฐ„์˜ ๋‹ค๋ฅธ ์ ์ด ์žˆ๋Š”๋ฐ, ํŠนํžˆ loader๊ฐ€ ๋ˆˆ์— ๋ˆ๋‹ค.

parcel์€ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ํŠธ๋žœ์ŠคํŒŒ์ผ๋Ÿฌ๋ฅผ ๋‚ด์žฅ ์ง€์›ํ•˜์ง€๋งŒ ์›นํŒฉ์€ ๊ทธ๋ ‡์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ง์ ‘ loader๋ฅผ ์„ค์ •ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

// const path = require("path");
const HtmlPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
  // ํŒŒ์ผ์„ ์ฝ์–ด๋“ค์ด๋Š” ์ง„์ž…์  ์„ค์ •
  entry: "./src/main.js",

  // ๊ฒฐ๊ณผ๋ฌผ ๋ฐ˜ํ™˜ ์˜ต์…˜
  output: {
    // ๊ธฐ๋ณธ์€ path dist, filename main.js
    // path: path.resolve(__dirname, "dist"),
    // filename: "mai.js",
    clean: true,
    // ๊ธฐ์กด ๋นŒ๋“œ ๊ฒฐ๊ณผ ์ œ๊ฑฐ
  },

  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader", "postcss-loader"],
        // ์ˆœ์„œ ์ค‘์š”, ๋’ค์—์„œ๋ถ€ํ„ฐ ๋กœ๋“œ
      },
      {
        test: /\.js$/,
        use: ["babel-loader"],
      },
    ],
  },

  // ๋ฒˆ๋“ค๋ง ํ›„ ๊ฒฐ๊ณผ๋ฌผ์˜ ์ฒ˜๋ฆฌ ๋ฐฉ์‹
  plugins: [
    new HtmlPlugin({
      template: "./index.html",
    }),
    // ๋ณต์‚ฌํ•ด์„œ ๋ชฉํ‘œ ํด๋”(dist)๋กœ copyํ•ด์คŒ
    new CopyPlugin({
      patterns: [{ from: "statics" }],
    }),
  ],
};

์„ค์น˜๋œ ํŒจํ‚ค์ง€๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค์ •ํ•œ webpack.config.js ํŒŒ์ผ์ด๋‹ค. ์ฃผ์„์œผ๋กœ ๋‹ฌ๋ฆฐ ์„ค๋ช…๋ฌธ๊ตฌ ์ฒ˜๋Ÿผ ๋‹ค์–‘ํ•œ ๋ถ€๋ถ„์„ ์„ธ์„ธํ•˜๊ฒŒ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ›„๊ธฐ

๋ฒˆ๋“ค๋ง์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ณ  ๊ฐ€์žฅ ๋Œ€์ค‘์ ์ธ webpack๊ณผ parcel์„ ์กฐ๊ธˆ ๊ฑด๋“œ๋ ค๋ดค์ง€๋งŒ ๋Œ€ํ˜• ํ”„๋กœ์ ํŠธ๋ฅผ ํ•ด ๋ณธ ๊ฒฝํ—˜์ด ์—†์–ด์„œ์ธ์ง€ ๋ชธ์— ์™€๋‹ฟ๋Š” ๋Š๋‚Œ์€ ์•„๋‹ˆ๋‹ค.

๊ทธ๋ž˜๋„ ๊ทธ ํ•„์š”์„ฑ์€ ๋Š๊ปด์ง„๋‹ค.

ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž๋ผ๋ฉด ๋‹ค์–‘ํ•œ ๋„๊ตฌ๋“ค์„ ๋งŽ์ด ์ด์šฉํ•˜๋Š”๋ฐ ๋ธŒ๋ผ์šฐ์ €๋Š” HTML, CSS, JS ํŒŒ์ผ๋งŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋•Œ ๋ฒˆ๋“ค๋Ÿฌ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ๊ฐœ๋ฐœ ํŽธ์˜์„ฑ์„ ์œ„ํ•ด ์‚ฌ์šฉํ–ˆ๋˜ ๋„๊ตฌ๋“ค์„ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์•Œ ์ˆ˜ ์žˆ๋Š” ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๊ฒƒ.

ํ”„๋ ˆ์ž„์›Œํฌ๋‚˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๊ฐœ๋ฐœํ•˜๋Š” ํ˜„์žฌ ํŠธ๋ Œ๋“œ์—์„œ๋Š” ํ•„์ˆ˜์ ์ด๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ๊ฒ ๋‹ค.

์—ฌ๋‹ด

๊ณผ๊ฑฐ์— ๊ธฐ๋ณธ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ™˜๊ฒฝ์—์„œ ๋ฆฌ๋•์Šค ํŒจํ‚ค์ง€๋ฅผ ์ด์šฉํ•ด๋ณด๋ ค๊ณ  ์‹œ๋„ํ•œ ์ ์ด ์žˆ๋‹ค.

ํ•˜์ง€๋งŒ ๋ฆฌ๋•์Šค ํŒจํ‚ค์ง€ ๋‚ด๋ถ€๊ฐ€ ๋ชจ๋“ˆ์„ importํ•  ๋•Œ ๋’ค์— ํ™•์žฅ์ž๋ฅผ ์ƒ๋žตํ•œ ํ˜•ํƒœ์˜€๊ธฐ ๋•Œ๋ฌธ์— ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

์ด๋•Œ parcel์„ ์ด์šฉํ•ด ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์—ˆ๋Š”๋ฐ ๋ฌธ๋“ ์ƒ๊ฐ๋‚œ๋‹ค.

profile
ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž๋กœ ๊ฑธ์–ด๊ฐ€๋Š” ์ค‘์ž…๋‹ˆ๋‹ค.
post-custom-banner

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