-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.ts
103 lines (89 loc) · 2.06 KB
/
next.config.ts
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
import { NextSidebuild, withNextSidebuild } from "@hazae41/next-sidebuild";
import type { NextConfig } from "next";
import path from "node:path";
async function compileServiceWorker(wpconfig: any) {
await NextSidebuild.compile({
/**
* Name of your script for display on logs
*/
name: "service_worker",
/**
* Use "webworker" for in-worker scripts or "web" for in-page scripts
*/
target: "webworker",
/**
* Your script source code path
*/
entry: "./src/scripts/service_worker/index.ts",
output: {
/**
* Output file relative to `./out`
*/
filename: "./service_worker.js",
/**
* DNTUYKWYD
*/
path: path.join(process.cwd(), ".webpack")
},
/**
* Use same config as Next.js
*/
mode: wpconfig.mode,
resolve: wpconfig.resolve,
resolveLoader: wpconfig.resolveLoader,
module: wpconfig.module,
plugins: wpconfig.plugins,
/**
* Configure minimizer
*/
optimization: {
minimize: true,
minimizer: wpconfig.optimization.minimizer
},
/**
* DNTUYKWYD
*/
devtool: false,
})
}
const nextConfig: NextConfig = withNextSidebuild({
/* config options here */
reactStrictMode: true,
/**
* Recommended in order to output the webapp as HTML
*/
output: "export",
/**
* Recommended in order to get deterministic build ID
*/
generateBuildId() {
return "immutable"
},
sidebuilds: function* (wpconfig: any) {
yield compileServiceWorker(wpconfig);
},
async headers() {
return [
{
source: "/:path*",
headers: [
/**
* Recommended in order to be embedded with strong restrictions
*/
{
key: "Allow-CSP-From",
value: "*"
},
/**
* Mandatory in order to get almost immutable caching
*/
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
}
]
}
]
}
});
export default nextConfig;