-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.config.js
93 lines (91 loc) · 2.77 KB
/
webpack.client.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
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
const path = require('path');
const HTMLWebpackPlugins = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const NODE_ENV = process.env.NODE_ENV;
module.exports = {
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.css', '.scss'],
},
mode: NODE_ENV ? NODE_ENV : 'development',
entry: path.resolve(__dirname, 'src/index.tsx'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js',
},
watchOptions: {
ignored: /node_modules/,
poll: 1000
},
module: {
rules: [
{
test: /\.[tj]sx?$/,
exclude: [/node_modules/, path.resolve(__dirname, 'src/server/server.js')],
use: ['ts-loader'],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-modules-typescript-loader?modules',
{
loader: 'css-loader',
options: {
modules: {
mode: 'local',
localIdentName: '[name]__[local]__[hash:base64:5]',
auto: /\.module\.\w+$/i,
},
},
},
'sass-loader',
],
},
{
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader'],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
},
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/',
},
}
],
},
],
},
plugins: [
new HTMLWebpackPlugins({
template: path.resolve(__dirname, 'public/index.html'),
}),
new MiniCssExtractPlugin()
],
devServer: {
port: 3005,
open: true,
hot: true,
historyApiFallback: true,
},
devtool: 'source-map',
};