-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
77 lines (69 loc) · 1.92 KB
/
webpack.common.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: './src/index.tsx',
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(jpe?g|gif|png|webp)$/,
type: 'asset',
},
{
test: /\.svg$/i,
use: ['@svgr/webpack'],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
alias: {
apis: path.resolve(__dirname, 'src/apis/'),
assets: path.resolve(__dirname, 'src/assets/'),
components: path.resolve(__dirname, 'src/components/'),
constants: path.resolve(__dirname, 'src/constants/'),
hooks: path.resolve(__dirname, 'src/hooks/'),
mocks: path.resolve(__dirname, 'src/mocks/'),
pages: path.resolve(__dirname, 'src/pages/'),
store: path.resolve(__dirname, 'src/store/'),
styles: path.resolve(__dirname, 'src/styles/'),
type: path.resolve(__dirname, 'src/type/'),
utils: path.resolve(__dirname, 'src/utils/'),
},
},
output: {
filename: '[name].[contenthash].bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
publicPath: '/',
},
devServer: {
hot: true,
open: true,
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'public', 'index.html'),
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
generateStatsFile: true,
statsFilename: 'bundle-report.json',
}),
new webpack.DefinePlugin({
PRODUCT_ENV: JSON.stringify(process.env.NODE_ENV),
MOCKING_ENV: JSON.stringify(process.env.MOCKING_ENV),
}),
],
};