This repository was archived by the owner on Dec 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.prod.config.js
More file actions
92 lines (87 loc) · 2.33 KB
/
webpack.prod.config.js
File metadata and controls
92 lines (87 loc) · 2.33 KB
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
const path = require("path");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const WORKER_FILE = path.resolve('src/js/service-worker/worker.js');
const pathsToClean = [
'./dist/js',
'./dist/worker.js'
];
// the clean options to use
const cleanOptions = {
exclude: ['.gitkeep'],
verbose: true,
dry: false,
watch: true
};
module.exports = {
mode: "production",
entry: [
"babel-polyfill",
path.resolve('src/js/main')
],
watch: false,
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules|worker\.js|service-worker/,
use: {
loader: 'babel-loader',
options: {
presets: [
"react",
["env", {
targets: {
"browsers": [
"last 2 versions",
"safari >= 7"
]
}
}]
]
}
}
}
]
},
plugins: [
new CleanWebpackPlugin(pathsToClean, cleanOptions),
new WorkboxPlugin.InjectManifest({
swSrc: WORKER_FILE,
swDest: './../worker.js',
importWorkboxFrom: 'local',
globDirectory: './dist/',
globPatterns: [
'index.html',
'manifest.json',
'robots.txt',
'img/**/*.svg',
'img/**/*.jpg',
'img/**/*.png',
'css/*.css',
'data/**/*.json',
'fonts/local/*.{woff,woff2}',
],
modifyUrlPrefix: {
'': '/'
}
})
],
node: false,
output: {
path: path.resolve("dist/js"),
publicPath: "/js/",
filename: 'bundle.js'
},
resolve: {
modules: [
path.resolve('src/js'),
path.resolve('node_modules')
],
extensions: [
'.jsx',
'.js',
'.json'
]
}
};