generated from yuta-ike/next-ts-tailwind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
68 lines (66 loc) · 1.73 KB
/
next.config.mjs
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
import sectionize from "remark-sectionize"
import rehypePrism from "@mapbox/rehype-prism"
import remarkGfm from "remark-gfm"
import { codeHighlight } from "./plugin/code-highlight.mjs"
import { tocExtract } from "./plugin/toc-extract.mjs"
export default {
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
reactStrictMode: true,
swcMinify: true,
async redirects() {
return process.env.NODE_ENV === "development"
? []
: [
{
source: "/:property/_snippet/:any*",
destination: "/404",
permanent: true,
},
]
},
webpack(config, options) {
if (!options.isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
path: false,
}
}
config.module.rules.push({
test: { and: [/_snippet/, /\.html$/] },
use: [
options.defaultLoaders.babel,
{
loader: "@mdx-js/loader",
options: {
rehypePlugins: [rehypePrism, codeHighlight],
remarkPlugins: [],
providerImportSource: "@mdx-js/react",
},
},
{
loader: "./loaders/html-snippet-loader.js",
ident: "html-snippet-loader",
},
],
})
config.module.rules.push({
test: /\.mdx$/,
use: [
options.defaultLoaders.babel,
{
loader: "@mdx-js/loader",
options: {
rehypePlugins: [rehypePrism, codeHighlight, tocExtract],
remarkPlugins: [sectionize, remarkGfm],
providerImportSource: "@mdx-js/react",
},
},
{
loader: "./loaders/mdx-meta-loader.js",
ident: "mdx-meta-loader",
},
],
})
return config
},
}