-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
91 lines (90 loc) · 2.48 KB
/
webpack.config.prod.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
const HTMLplugin = require('html-webpack-plugin');
const cssMinimizer = require('css-minimizer-webpack-plugin');
const terserPlugin = require('terser-webpack-plugin');
const { InjectManifest } = require("workbox-webpack-plugin");
const copyPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
mode: 'production',
entry: '/src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name][fullhash].bundle.js',
clean: true,
},
resolve: {
extensions: ['.js', '.jsx', '.mjs'],
alias: {
'@src': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
'@images': path.resolve(__dirname, 'src/assets/images'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@context': path.resolve(__dirname, 'src/context'),
'@routes': path.resolve(__dirname, 'src/routes'),
'@styles': path.resolve(__dirname, 'src/assets/styles'),
}
},
module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
use: {
loader: "babel-loader"
}
},
{
test: /\.(png|jpg|ico|svg|jpeg|webp)$/,
type: 'asset/resource',
generator: {
filename: 'assets/images/[hash][ext]',
}
},
{
test: /\.html$/,
use: [{
loader: 'html-loader'
}]
}
]
},
plugins: [
new HTMLplugin({
inject: true,
template: '/public/index.html',
filename: './index.html',
title: 'Tasks manager',
favicon: './public/favicon.ico'
}),
new copyPlugin({
patterns: [
{ from: "./public/manifest.json", to: "" },
{ from: "./public/logo192.png", to: "" },
{ from: "./public/logo512.png", to: "" },
{ from: "./public/favicon.ico", to: "" },
]
}),
new InjectManifest({
swSrc: "./src/sw.js",
swDest: "./sw.js",
})
],
optimization: {
minimize: true,
minimizer: [
new cssMinimizer,
new terserPlugin,
],
splitChunks: {
chunks: 'all',
}
}
};