Webpack

webpack

왜 Webpack이 등장하게 되었을까?

그렇다면 여러 개로 호출하면 해결되는게 아닐까?

이를 해결하기 위해 Webpack이 등장하게 되었습니다.

Webpack이란?

Bundle이란?

그렇다면 왜 Webpack을 사용해야할까?

Browsify, Grunt, Gulp 등의 도구들은 webpack과 무슨 차이가 있을까?

Webpack Core Concept

Entry

module.exports = {
  entry: './path/to/my/entry/file.js'
};

Output

const path = require('path');

module.exports = {
  entry: './path/to/my/entry/file.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'my-first-webpack.bundle.js'
  }
};

Loaders

const path = require('path');

module.exports = {
  output: {
    filename: 'my-first-webpack.bundle.js'
  },
  module: {
    rules: [
      { test: /\.txt$/, use: 'raw-loader' }
    ]
  }
};

Plugins

const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
const webpack = require('webpack'); //to access built-in plugins

module.exports = {
  module: {
    rules: [
      { test: /\.txt$/, use: 'raw-loader' }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({template: './src/index.html'})
  ]
};

Mode

module.exports = {
  mode: 'production'
};

Browser Compatibility

웹팩은 ES5를 사용하는 모든 브라우저를 지원합니다. 단 IE8의 아래 버젼은 지원하지 않습니다.

참고링크