-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
122 lines (121 loc) · 3.42 KB
/
webpack.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
mode: 'production',
entry: './src/frontend/App.js',
output: {
path: path.resolve(__dirname + '/dist/'),
publicPath: '/',
filename: 'assets/bundle.js'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin(),
new OptimizeCSSAssetsPlugin({})
]
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
localIdentName: '[name]_[local]_[contenthash:base64:5]'
}
}
}
],
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
exclude: /node_modules/
},
{
test: /\.(png|jp(e*)g)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'assets/img/[contenthash]-[name].[ext]'
}
}
]
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
exclude: [path.resolve(__dirname, 'src/frontend/images')],
use: [
{
loader: 'file-loader',
options: {
name: 'assets/fonts/[name].[ext]'
}
}
]
},
{
test: /\.svg$/,
include: [path.resolve(__dirname, 'src/frontend/images')],
use: [
{
loader: 'file-loader',
options: {
name: 'assets/img/[name].[ext]'
}
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'REACT_APP_VERSION': JSON.stringify(process.env.npm_package_version || '')
}),
new MiniCssExtractPlugin({
filename: 'assets/[name].css',
chunkFilename: 'assets/[id].css'
}),
new HtmlWebpackPlugin({
template: './src/index.template.html',
inject: 'body',
filename: 'index.html',
favicon: './src/favicon.ico'
})
],
resolve: {
modules: ['node_modules'],
alias: {
Components: path.resolve('./src/frontend/Components'),
Containers: path.resolve('./src/frontend/Containers'),
css: path.resolve('./src/frontend/css'),
Images: path.resolve('./src/frontend/images'),
Assets: path.resolve('./src/backend/assets'),
Routes: path.resolve('./src/backend/routes')
},
extensions: ['.js', '.jsx', '.json', '.css', '.scss'],
fallback: {
fs: false,
net: false,
module: false
}
},
target: 'web'
};