-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
82 lines (74 loc) · 2.34 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
const path = require('path')
const EncodingPlugin = require('webpack-encoding-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const { GenerateSW } = require('workbox-webpack-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const encodingPlugin = new EncodingPlugin({
encoding: 'UTF-8'
})
const minimize = {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 5
}
}),
new OptimizeCSSAssetsPlugin({})
]
}
module.exports = {
entry: [
'./app/index.js'
],
output: {
publicPath: '/',
path: path.join(__dirname, '/dist'),
filename: 'main.[hash].js'
},
module: {
rules: [
{ test: /\.(js|jsx)$/, use: ['babel-loader'], include: path.join(__dirname, 'app') },
{ test: /\.(scss)$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'] },
{ test: /\.(css)$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },
{ test: /\.js$/, use: ['i18next-resource-store-loader'], include: path.join(__dirname, './app/translations') },
{ test: /\.jpe?g$|\.ico$|\.vtt$|\.md$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/, loader: 'file-loader?name=[path][name].[ext]' }
]
},
plugins: [
encodingPlugin,
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[id].css'
}),
new HtmlWebpackPlugin({
template: 'index.html.ejs',
inject: false,
filename: 'index.html',
title: 'Gaming Ever After'
}),
new ManifestPlugin({
fileName: 'asset-manifest.json'
}),
new GenerateSW({
exclude: ['index.html', '/index.html']
}),
new CopyPlugin({
patterns: [
{ from: './pwa', to: '' },
{ from: './assets/css/bootstrap-4.2.1.min.css', to: './assets/css' },
{ from: './assets/js/core-js-3.6.4.min.js', to: './assets/js' },
{ from: './assets/js/runtime-0.13.3.min.js', to: './assets/js' }
]
})
],
optimization: process.env.NODE_ENV === 'production' ? minimize : {},
devServer: {
port: 3000,
historyApiFallback: true
}
}