-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
50 lines (46 loc) · 1.59 KB
/
Copy pathnext.config.ts
File metadata and controls
50 lines (46 loc) · 1.59 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
import type { NextConfig } from "next";
import path from "path";
import fs from "fs";
const nextConfig: NextConfig = {
output: "export",
// github-slugger·feed는 ESM 전용 패키지. next/jest가 이를 SWC로 변환하도록
// 허용해야 jest에서 import가 가능하다(목차 slug 생성, RSS/Atom 피드 생성).
transpilePackages: ["github-slugger", "feed"],
images: {
unoptimized: true,
},
trailingSlash: true,
// webpack 설정 공존 시 Turbopack 빌드 에러 방지용 (Next.js 16)
turbopack: {},
webpack: (config, { dev }) => {
if (dev) {
config.plugins.push({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
apply(compiler: any) {
compiler.hooks.afterCompile.tap(
"ContentWatchPlugin",
(compilation: any) => {
const contentDir = path.join(process.cwd(), "content/posts");
try {
if (!fs.existsSync(contentDir)) return;
const files = fs.readdirSync(contentDir);
for (const file of files) {
if (file.endsWith(".md") || file.endsWith(".mdx")) {
compilation.fileDependencies.add(
path.join(contentDir, file)
);
}
}
compilation.contextDependencies.add(contentDir);
} catch {
// 디렉토리 접근 실패 시 감시 생략 (dev 서버는 계속 동작)
}
}
);
},
});
}
return config;
},
};
export default nextConfig;