Open jerrybabah opened 4 years ago
$ yarn add --dev webpack webpack-cli
entry 파일을 시작으로 dependency graph를 만들어 프로젝트의 모든 모듈을 몇 개의 번들 파일로 만든다.
const path = require('path'); const HTMLWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, 'dist'), filename: '[name].js', // chunkFilename: 'chunk.js', // publicPath: '/', }, module: { rules: [ { test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }, { test: /\.(js|ts)$/, use: { loader: 'babel-loader', }, }, ], }, plugins: [ new HTMLWebpackPlugin({ template: './public/index.html', }), new MiniCssExtractPlugin({ fileName: 'style.css', }), ], }
{ entry: string, }
{ output: { path: string, filename: string, }, }
{ module: { rules: [ // loader { test: RegExp, use: string | string[] | { loader: string, options: object }, }, ], }, }
{ plugins: [ new InstalledPlugins({...options}), ], }
설치
웹팩의 역할
webpack.config.js 예시
기본 개념
entry
output
module
plugins