-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
110 lines (108 loc) · 2.97 KB
/
webpack.config.js
File metadata and controls
110 lines (108 loc) · 2.97 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const webpack = require("webpack");
const dotenv = require("dotenv");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
dotenv.config();
module.exports = {
entry: "./src/index.js",
mode: "development",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
publicPath: "/",
},
resolve: {
extensions: [".js", ".jsx"],
alias: {
assets: path.resolve(__dirname, "src/assets"),
commons: path.resolve(__dirname, "src/commons"),
components: path.resolve(__dirname, "src/components"),
configs: path.resolve(__dirname, "src/configs"),
constants: path.resolve(__dirname, "src/constants"),
hooks: path.resolve(__dirname, "src/hooks"),
pages: path.resolve(__dirname, "src/pages"),
routes: path.resolve(__dirname, "src/routes"),
services: path.resolve(__dirname, "src/services"),
store: path.resolve(__dirname, "src/store"),
styles: path.resolve(__dirname, "src/styles"),
utils: path.resolve(__dirname, "src/utils"),
},
},
module: {
rules: [
{
test: /\.(mp3|wav|ogg)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[hash].[ext]",
outputPath: "assets/audio",
esModule: false,
},
},
],
},
{
test: /\.(png|jpe?g|gif|svg|woff2?|ttf|eot)$/i,
type: "asset/resource",
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: "babel-loader",
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./public/index.html",
favicon: "./public/gotcha.ico",
filename: "index.html",
}),
new MiniCssExtractPlugin({
filename: "style.css",
}),
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env),
}),
new FaviconsWebpackPlugin({
logo: "src/assets/commons/logo.png",
manifest: "./public/manifest.json",
}),
new ESLintPlugin({
extensions: ["js", "jsx", "ts", "tsx"], // 검사할 확장자
emitWarning: true,
}),
],
optimization: {
minimize: true, // 최소화는 그대로 진행
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: false, // console.log 제거x
},
},
extractComments: true, // 주석 제거
}),
],
},
devServer: {
static: "./dist",
port: 3000,
historyApiFallback: true,
},
};