핵심 개념

module.exports = {
  // Entry: 모듈간의 의존성 그래프 생성을 위한 시작점
  entry: './src/index.js',
  
  // Output: 생성한 번들 파일의 위치와 이름
  output: {
    filename: 'bundle.[contenthash].js',
    path: path.resolve(__dirname, 'dist'),
  },
  
  // Loaders: Javascript, JSON 외 파일들의 변환, 처리를 수행
  module: {
    rules: [
      {
        test: /\\.css$/,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\\.(png|svg|jpg|jpeg|gif)$/i,
        type: 'asset/resource',
      },
    ],
  },
  
  // Plugins: 번들링 중 커스텀 작업을 위한 설정 수행
  // Loaders가 파일 변환에 초점을 맞췄다면, Plugins는 환경 변수 주입, HTML 생성 등 번들링에 초점
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Webpack Example',
      template: './src/index.html'
    }),
    new CleanWebpackPlugin(),
  ],
  
  // Mode: Spring의 Profile과 비슷한 역할, development, production, none 중 선택
  mode: 'development',
};