-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.service-worker.config.js
49 lines (48 loc) · 1.24 KB
/
webpack.service-worker.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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: {
// ensure this key matches the "chunks" list in the html webpack plugin config below
registerServiceWorker: "./src/push-notifications/registerServiceWorker.ts",
serviceWorker: "./src/push-notifications/serviceWorker.ts",
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-typescript",
[
"@babel/preset-env",
{ exclude: ["@babel/plugin-transform-regenerator"] },
],
],
},
},
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts", ".js"],
},
plugins: [
new HtmlWebpackPlugin({
chunks: ["registerServiceWorker"],
template: "./src/push-notifications/index.html",
scriptLoading: "blocking",
}),
],
output: {
clean: true,
publicPath: ".",
filename: (pathData) =>
pathData.chunk.name === "serviceWorker"
? "[name].js"
: "[name].[contenthash].js",
path: path.resolve(__dirname, "dist/push-notifications"),
},
};