-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.build.js
132 lines (130 loc) · 3.88 KB
/
webpack.config.build.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
const _ = require('lodash')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const { default: SitemapWebpackPlugin } = require('sitemap-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const WorkboxPlugin = require('workbox-webpack-plugin')
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin')
const createPages = require('./createPages')
const publicPath = 'https://fakundo.github.io/tarkov-raid-items/'
const outputPath = path.resolve(__dirname, 'build')
const pages = createPages(publicPath)
module.exports = {
entry: path.resolve(__dirname, 'src/index'),
output: {
publicPath,
filename: 'bundle.js',
path: outputPath,
},
target: 'web',
mode: 'production',
devtool: 'source-map',
plugins: [
...pages.map(
pageOptions =>
new HtmlWebpackPlugin({
...pageOptions,
alternatives: _.reject(pages, { lang: pageOptions.lang }),
minify: { collapseWhitespace: true, minifyJS: true, minifyCSS: true },
inject: 'body',
hash: true,
template: path.resolve(__dirname, 'src/template.ejs'),
poster: {
url: `${publicPath}poster.jpg`,
width: '600',
height: '600',
},
googleTagKey: 'G-SVCPTV948J',
buildTime: new Date(),
}),
),
new CopyWebpackPlugin({
patterns: [{ from: 'src/assets/poster.jpg', force: true }],
}),
new CleanWebpackPlugin(),
new SitemapWebpackPlugin({
base: publicPath,
paths: pages,
options: {
skipgzip: true,
},
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
new FaviconsWebpackPlugin({
logo: path.resolve(__dirname, 'src/assets/favicon.png'),
publicPath,
outputPath,
favicons: {
appName: 'Tarkov Raid Items',
appDescription:
'Interactive list of quest items in Escape from Tarkov (EFT) game needed to be found in raid. Progress tracker.',
version: null,
developerURL: null,
developerName: null,
background: '#FFFFFF',
theme_color: '#000000',
start_url: publicPath,
path: publicPath,
},
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
maximumFileSizeToCacheInBytes: 1024 * 1024 * 3,
}),
],
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(png|otf)$/,
use: 'file-loader',
},
{
test: /\.svg$/,
use: 'svg-sprite-loader',
},
{
test: /\.po$/,
use: 'react-localized-loader',
},
],
},
resolve: {
alias: {
assets: path.resolve(__dirname, 'src/assets'),
components: path.resolve(__dirname, 'src/components'),
constants: path.resolve(__dirname, 'src/constants'),
data: path.resolve(__dirname, 'src/data'),
hooks: path.resolve(__dirname, 'src/hooks'),
locales: path.resolve(__dirname, 'src/locales'),
providers: path.resolve(__dirname, 'src/providers'),
utils: path.resolve(__dirname, 'src/utils'),
},
},
optimization: {
minimizer: [
new ImageMinimizerPlugin({
minimizer: { implementation: ImageMinimizerPlugin.sharpMinify },
generator: [
{
// You can apply generator using `?as=webp`, you can use any name and provide more options
preset: 'webp',
implementation: ImageMinimizerPlugin.sharpGenerate,
options: { encodeOptions: { webp: { quality: 90 } } },
},
],
}),
],
},
}