Skip to content

Commit 781eac1

Browse files
committed
typescriptアセットのcache-controlを修正、404の場合もダミーのファイルを返すようにする
1 parent 1d5d668 commit 781eac1

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

next.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const nextConfig: NextConfig = {
1717
},
1818
serverExternalPackages: ["@prisma/client", ".prisma/client"],
1919
async headers() {
20-
// pyodideをworkerで動作させるために必要
2120
return [
2221
{
22+
// pyodideをworkerで動作させるために必要
2323
source: "/:path*",
2424
headers: [
2525
{
@@ -32,6 +32,15 @@ const nextConfig: NextConfig = {
3232
},
3333
],
3434
},
35+
{
36+
source: "/typescript/:path*",
37+
headers: [
38+
{
39+
key: "Cache-Control",
40+
value: "public, max-age=31536000, immutable",
41+
},
42+
],
43+
},
3544
];
3645
},
3746
webpack: (config, { isServer }) => {

scripts/copyAllDTSFiles.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ await fs.mkdir(destDir, { recursive: true });
1414
for (const libFile of libFiles) {
1515
const srcPath = `./node_modules/typescript/lib/${libFile}`;
1616
const destPath = `${destDir}${libFile}`;
17-
if(existsSync(srcPath)) {
17+
if (existsSync(srcPath)) {
1818
await fs.copyFile(srcPath, destPath);
1919
console.log(`Copied ${libFile} to ${destPath}`);
2020
} else {
2121
console.warn(`Source file does not exist: ${srcPath}`);
22+
await fs.writeFile(
23+
destPath,
24+
`// ${libFile} not found in node_modules/typescript/lib/`
25+
);
2226
}
2327
}

0 commit comments

Comments
 (0)