-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (82 loc) · 2.33 KB
/
webpack.config.js
File metadata and controls
83 lines (82 loc) · 2.33 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
// webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/main.tsx',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
target: 'web',
devServer: {
historyApiFallback: true,
port: 3000,
hot: true,
open: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],
alias: {
src: path.resolve(__dirname, 'src'),
'@types': path.resolve(process.cwd(), 'src/lib/types'),
'@utils': path.resolve(process.cwd(), 'src/lib/utils'),
'@assets': path.resolve(process.cwd(), 'public/assets'),
'@components': path.resolve(process.cwd(), 'src/view/components'),
'@pages': path.resolve(process.cwd(), 'src/view/pages'),
'@service': path.resolve(process.cwd(), 'src/service'),
'@hooks': path.resolve(process.cwd(), 'src/lib/hooks'),
'@constants': path.resolve(process.cwd(), 'src/lib/const'),
'@styles': path.resolve(process.cwd(), 'src/view/styles'),
'@contexts': path.resolve(process.cwd(), 'src/lib/contexts'),
'@api': path.resolve(process.cwd(), 'src/service/api'),
},
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
['@babel/preset-react', { runtime: 'automatic' }],
'@babel/preset-typescript',
],
},
},
},
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.(png|jpe?g|gif|svg)$/,
type: 'asset/resource',
},
],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'public/index.html'),
scriptLoading: 'module', // ESM 지원
inject: 'body', // body에 script 넣기
}),
],
};