-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
60 lines (57 loc) · 1.61 KB
/
webpack.common.js
File metadata and controls
60 lines (57 loc) · 1.61 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { resolve } = require('path');
const rootPath = resolve();
const webpackCommonConfig = {
// entry is set in each environment config (web/extension)
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
'@': resolve(rootPath, './src/'),
},
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
// Webpack(웹팩)에서 Typescript(타입스크립트)를 사용하기 위해 js|jsx를 ts|tsx로 수정 후 ts-loader를 추가
// ts-loader의 옵션은 성능 향상을 위해서
{
test: /\.(ts|tsx)$/,
use: ['babel-loader', 'ts-loader'],
exclude: /node_modules/,
},
{
test: /\.(js|jsx)$/,
use: ['babel-loader'],
exclude: /node_modules/,
},
// 파일 로더
{
test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: {
loader: 'file-loader',
options: {
name: 'assets/[name].[contenthash].[ext]',
},
},
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
}),
/**
* @description 컴파일과 타입 체크를 코드의 양이 많아질수록 빌드 속도도 느려진다.
* 다음 플러그인은 타입검사를 별도로 실행하는 웹팩 플러그인
*/
new ForkTsCheckerWebpackPlugin(),
],
};
module.exports = {
webpackCommonConfig,
};