01
설정
기본 설정
entry와 output이 번들링을 정의합니다.
webpack
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve("dist"),
filename: "bundle.js",
},
};로더
로더는 JS가 아닌 모듈을 변환합니다.
webpack
module: {
rules: [
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
{ test: /\.ts$/, use: "ts-loader" },
],
}플러그인
플러그인으로 webpack 기능을 확장합니다.
webpack
const HtmlWebpackPlugin = require("html-webpack-plugin");
plugins: [
new HtmlWebpackPlugin({ template: "./src/index.html" }),
]02
최적화
코드 스플리팅
코드를 더 작은 청크로 분할합니다.
webpack
optimization: {
splitChunks: {
chunks: "all",
},
}개발 서버
HMR을 지원하는 개발 서버입니다.
webpack
devServer: {
contentBase: "./dist",
hot: true,
port: 3000,
}Was this helpful?