This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.config.js
178 lines (174 loc) · 4.19 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
const webpack = require('webpack')
const path = require('path')
const config = require('config')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const ProgressPlugin = require('progress-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const isDev = process.env.NODE_ENV === 'development'
const sourceMap = isDev
const webpackConfig = {
mode: isDev ? 'development' : 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].[contenthash].js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '/'
}
},
{
loader: 'css-loader',
options: {
url: false,
sourceMap
}
},
{
loader: 'postcss-loader',
options: {
sourceMap
}
},
{
loader: 'resolve-url-loader',
options: {
sourceMap
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.svg$/,
use: 'file-loader'
},
{
test: /\.(gif|png|jpe?g)$/i,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images',
name: '[name].[ext]',
publicPath: '/images'
}
},
{
loader: 'image-webpack-loader',
options: {
disable: true,
bypassOnDebug: true,
gifsicle: {
interlaced: false
},
optipng: {
optimizationLevel: 7
},
pngquant: {
speed: 4
},
mozjpeg: {
progressive: true
}
}
}
]
}
]
},
resolve: {
extensions: [
'.js',
'.jsx',
'.png',
'.svg'
],
alias: {
'@': path.resolve(path.resolve(__dirname, './'), 'src')
}
},
plugins: [
new NodePolyfillPlugin(),
new webpack.HotModuleReplacementPlugin(),
new ProgressPlugin(true),
new webpack.DefinePlugin({ CONFIG: JSON.stringify(config) }),
new FaviconsWebpackPlugin({
logo: path.join(path.resolve(__dirname, './'), '/src/assets/images/favicon.png'),
prefix: 'images/favicons/',
favicons: {
appName: 'Fuse Staking',
appDescription: 'Fuse Staking DApp',
developerName: 'Lior Agnin',
icons: {
android: true,
appleIcon: true,
appleStartup: false,
coast: false,
favicons: true,
firefox: false,
windows: false,
yandex: false
}
}
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false
}),
new MiniCssExtractPlugin(),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
appMountId: 'app',
filename: 'index.html',
template: path.join(__dirname, 'src', 'index.html'),
publicPath: '/'
})
],
optimization: {
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
},
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true
}
}
}
}
}
module.exports = (env, argv) => {
if (argv.hot) {
webpackConfig.output.filename = '[name].[fullhash].js'
}
return webpackConfig
}