-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
63 lines (62 loc) · 1.62 KB
/
webpack.config.js
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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
module.exports = {
entry: {
index: "./src/index.js",
courses: "./src/pages/courses.js",
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
clean: true,
},
devServer: {
static: "./dist",
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.s[ac]ss$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(png|jpeg|jpg|gif)$/,
type: "asset/resource",
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
chunks: ["index"],
filename: "index.html",
}),
new HtmlWebpackPlugin({
template: "./src/pages/courses.html",
chunks: ["courses"],
filename: "courses.html",
base: "pages",
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "src/assets/images/*"),
to: path.resolve(__dirname, "dist"),
context: "src",
},
],
}),
new BundleAnalyzerPlugin({
// Creates interactive treemap visualization of the contents of all your bundles
// localhost:8888
// 현재는 lodash가 가장 크고 자잘한 번들이 있지만, 중요한건 크기가 아니라
// index.bunlde.js과 courses.bundle.js에 중복으로 번들링되는 모듈이 있다는 것
}),
],
};