-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.js
100 lines (97 loc) · 2.63 KB
/
webpack.client.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
94
95
96
97
98
99
100
const path = require('path');
const dotenv = require('dotenv');
const TerserPlugin = require('terser-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
dotenv.config();
const NODE_ENV = process.env.NODE_ENV === 'production' ? 'production' : 'development';
module.exports = {
mode: NODE_ENV,
target: 'web',
entry: {
landingPage: './src/apps/landingPage/client.entry.jsx',
dashboard: './src/apps/dashboard/client.entry.jsx',
},
output: {
filename: '[name]/bundle.js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'@App': path.resolve(__dirname, 'src/apps'),
'@Core': path.resolve(__dirname, 'src/core'),
'@Public': path.resolve(__dirname, 'src/core/public'),
'@': path.resolve(__dirname, 'src'),
},
},
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
options: {
minimize: true,
},
},
{
test: /\.(mov|mp4|jpg|svg|gif|png|ico)$/,
loader: 'file-loader',
},
{
test: /\.(woff|woff2|ttf|svg|eot)$/,
loader: 'file-loader',
},
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|public|dist)/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'react-hot-loader/babel',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
],
},
},
},
{
test: /\.(scss|css)$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
],
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
splitChunks: {
// include all types of chunks
chunks: 'all',
},
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
filename: './landingPage/index.html',
template: './src/core/static/template.html',
favicon: './src/core/static/favicon.ico',
chunks: ['landingPage'],
}),
new HtmlWebpackPlugin({
inject: true,
filename: './dashboard/index.html',
template: './src/core/static/template.html',
favicon: './src/core/static/favicon.ico',
chunks: ['dashboard'],
}),
new HtmlWebpackPlugin({
filename: '404.html',
template: './src/core/static/404.html',
favicon: './src/core/static/favicon.ico',
}),
new MiniCssExtractPlugin(),
],
};