logo

JEONGGON

    블로그
github
mode
목 차
down-arrow

Webpack config

2024.03.20.

post-thumbnail

Webpack 설정 - config 파일

1. Webpack 설정 파일 생성

1-1. webpack.config.js

  • path : 파일, 디렉토리의 경로를 다룰 때, Node.js의 내장모듈인 path 모듈 사용
  • resolve() : 절대 경로 생성
    • ex) path.resolve(‘Users’, ‘jeonggon’, ‘index.html’) => ‘Users/jeonggon/index.html’
// webpack.config.js


const path = require("path");

module.exports = {
  // 개발 모드
  mode: 'development',
  // 시작점
  entry: path.resolve(__dirname, 'src/index.js'),
  // 웹팩을 통해 생성된 결과물
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
  }
}

- 만약 여러 개의 Entry point를 원한다면?

  • entry의 값을 객체로 만들기
// webpack.config.js

const path = require("path");

module.exports = {
  // ...
  entry: {
    main: path.resolve(__dirname, 'src/index.js'),
    // ...
  },
}
webpackbundleconfig
profile

조정곤

주니어 프론트엔드 개발자

github
linkedin
instagram
email

< 이전글

Webpack Plugin

다음글 >

Webpack gzip

Webpack 포스트 (13)

down-arrow
Webpack 소개Webpack importWebpack 폴더 및 파일 구조Webpack Babel LoaderWebpack DevtoolWebpack LoaderWebpack PluginWebpack configWebpack gzipWebpack 개발 서버Webpack 캐싱Webpack Bundle AnalyzerWebpack Resource Asset