-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
150 lines (147 loc) · 5.15 KB
/
next.config.ts
File metadata and controls
150 lines (147 loc) · 5.15 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import type { NextConfig } from "next";
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
import { PyodidePlugin } from "@pyodide/webpack-plugin";
import { version as pyodideVersion } from "pyodide/package.json";
initOpenNextCloudflareForDev();
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
experimental: {
useCache: true,
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
serverExternalPackages: ["@prisma/client", ".prisma/client"],
async headers() {
return [
{
// pyodideをworkerで動作させるために必要
source: "/:path*",
headers: [
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
],
},
{
source: "/typescript/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
];
},
webpack: (config, { isServer }) => {
config.plugins.push(
new PyodidePlugin({
// public/ 以下に書き出すと404
// ../public/ 以下に書き出すと Uncaught SyntaxError: Invalid or unexpected token (at layout.js:1073:29) エラーになる
// _next/static/ 以下ならとりあえずうごく
outDirectory: `static/pyodide/v${pyodideVersion}`,
})
);
// import hoge from "./file?raw" でfileの中身を文字列としてインポート
for (const rule of config.module.rules) {
if (rule.resourceQuery instanceof RegExp) {
// skip
} else if (Array.isArray(rule.resourceQuery?.not)) {
rule.resourceQuery.not.push(/raw/);
} else {
if (rule.resourceQuery) {
console.warn("resourceQuery already exists:", rule.resourceQuery);
}
rule.resourceQuery = { not: /raw/ };
}
}
config.module.rules.push({
resourceQuery: /raw/,
type: "asset/source",
});
return config;
},
async redirects() {
return [
["/cpp-1", "/cpp/0-intro"],
["/cpp-2", "/cpp/1-types-control"],
["/cpp-3", "/cpp/2-data-containers"],
["/cpp-4", "/cpp/3-pointers"],
["/cpp-5", "/cpp/4-functions"],
["/cpp-6", "/cpp/5-project-build"],
["/cpp-7", "/cpp/6-classes-basics"],
["/cpp-8", "/cpp/7-classes-advanced"],
["/cpp-9", "/cpp/8-inheritance"],
["/cpp-10", "/cpp/9-templates"],
["/cpp-11", "/cpp/10-stl-containers"],
["/cpp-12", "/cpp/11-stl-algorithms"],
["/cpp-13", "/cpp/12-raii-smart-ptrs"],
["/javascript-1", "/javascript/0-intro"],
["/javascript-2", "/javascript/1-basics"],
["/javascript-3", "/javascript/2-control"],
["/javascript-4", "/javascript/3-functions-closures"],
["/javascript-5", "/javascript/4-this"],
["/javascript-6", "/javascript/5-objects-prototype"],
["/javascript-7", "/javascript/6-classes"],
["/javascript-8", "/javascript/7-arrays"],
["/javascript-9", "/javascript/8-promise"],
["/javascript-10", "/javascript/9-async-await"],
["/python-1", "/python/0-intro"],
["/python-2", "/python/1-basics"],
["/python-3", "/python/2-collections"],
["/python-4", "/python/3-control-functions"],
["/python-5", "/python/4-modules"],
["/python-6", "/python/5-oop"],
["/python-7", "/python/6-file-io"],
["/python-8", "/python/7-exceptions"],
["/python-9", "/python/8-generators-decorators"],
["/ruby-1", "/ruby/0-intro"],
["/ruby-2", "/ruby/1-basics"],
["/ruby-3", "/ruby/2-control-methods"],
["/ruby-4", "/ruby/3-everything-object"],
["/ruby-5", "/ruby/4-collections"],
["/ruby-6", "/ruby/5-blocks-iterators"],
["/ruby-7", "/ruby/6-classes"],
["/ruby-8", "/ruby/7-modules"],
["/ruby-9", "/ruby/8-proc-lambda"],
["/ruby-10", "/ruby/9-stdlib"],
["/ruby-11", "/ruby/10-testing"],
["/ruby-12", "/ruby/11-metaprogramming"],
["/rust-1", "/rust/0-intro"],
["/rust-2", "/rust/1-basics"],
["/rust-3", "/rust/2-functions-control"],
["/rust-4", "/rust/3-ownership"],
["/rust-5", "/rust/4-borrowing-slices"],
["/rust-6", "/rust/5-structs-methods"],
["/rust-7", "/rust/6-enums-pattern"],
["/rust-8", "/rust/7-modules"],
["/rust-9", "/rust/8-collections-strings"],
["/rust-10", "/rust/9-error-handling"],
["/rust-11", "/rust/10-generics-traits"],
["/rust-12", "/rust/11-lifetimes"],
["/typescript-1", "/typescript/0-intro"],
["/typescript-2", "/typescript/1-types"],
["/typescript-3", "/typescript/2-objects-interfaces"],
["/typescript-4", "/typescript/3-function-types"],
["/typescript-5", "/typescript/4-combining-types"],
["/typescript-6", "/typescript/5-generics"],
["/typescript-7", "/typescript/6-classes"],
["/typescript-8", "/typescript/7-async-utilities"],
].map(([source, destination]) => ({
source,
destination,
permanent: true,
}));
},
};
export default nextConfig;