-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (85 loc) · 2.07 KB
/
webpack.config.js
File metadata and controls
86 lines (85 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const { optimize } = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
// 빌드시 css 파일을 사용하는 js파일별로 별도의 css 파일 추출해 번들에 추가
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { split } = require('lodash');
module.exports = {
entry: './src/index.js',
// app, vendor를 각각 번들로 생성 (chunk로 부름)
// entry: {
// app: './src/App.js',
// vendor: './src/VendorApp.js',
// // app: {
// // import: './src/App.js',
// // dependOn: 'shared',
// // },
// // vendor: {
// // import: './src/VendorApp.js',
// // dependOn: 'shared',
// // },
// // shared: 'lodash',
// },
mode: 'development',
devtool: false,
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
port: 4000,
},
optimization: {
minimize: false,
// splitChunks: 청크별로 공통된 모듈을 별도의 파일로 추출
splitChunks: {
chunks: 'all',
},
},
/**
* name: chunk 이름
* chunkhash: chunk 내용이 변경되면 hash 값이 변경됨
*
*/
output: {
publicPath: 'auto',
filename: '[name].[chunkhash].js',
clean: true,
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-react'],
},
},
{
test: /\.(png|jpg|gif|ico)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]',
publicPath: path.join(__dirname, 'dist'),
},
},
],
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
}),
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css',
}),
],
};