forked from vertx-china/vertx-china.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
142 lines (122 loc) · 3.48 KB
/
next.config.js
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
import { mdxOptions } from "./components/lib/mdx-options.js"
import ESLintPlugin from "eslint-webpack-plugin"
import styledJsx from "styled-jsx/webpack.js"
import svgToMiniDataURI from "mini-svg-data-uri"
import withBundleAnalyzer from "@next/bundle-analyzer"
const isProd = process.env.NODE_ENV === "production"
// configure base path based on environment variable `VERTX_WEBSITE_BASEPATH`
const basePath = (() => {
let p = process.env.VERTX_WEBSITE_BASEPATH || ""
if (!p.startsWith("/")) {
p = `/${p}`
}
if (p.endsWith("/")) {
p = p.substring(0, p.length - 1)
}
return p
})()
const config = {
env: {
basePath,
// URL to the website. MUST NOT end with a slash.
baseUrl: isProd ? `https://vertx.io${basePath}` : `http://localhost:3000${basePath}`,
buildDate: new Date().toISOString()
},
// also render markdown pages
pageExtensions: ["js", "jsx", "md", "mdx"],
// create a folder for each page
trailingSlash: true,
// opt-in to using SWC for minifying JavaScript
swcMinify: true,
// configure base path
basePath,
assetPrefix: basePath,
eslint: {
dirs: ["components", "pages", "docs/metadata"]
},
images: {
// make build compatible with next-optimized-images
disableStaticImages: true
},
// Sometimes it takes a long time (and a few retries) to fetch all
// contributors. Increase page generation timeout so the contributors can
// be fully fetched.
staticPageGenerationTimeout: 1000,
experimental: {
// our docs pages are very large - increase the limit here to disable
// warnings about page sizes
largePageDataBytes: 1024 * 1024
},
// list pages to export
exportPathMap() {
return {
"/": { page: "/" },
"/blog": { page: "/blog/[[...slug]]" },
"/channels": { page: "/channels" },
"/community": { page: "/community" },
"/docs": { page: "/docs/[[...slug]]" },
"/download": { page: "/download" },
"/faq": { page: "/faq" },
"/get-started": { page: "/get-started" },
"/introduction-to-vertx-and-reactive": { page: "/introduction-to-vertx-and-reactive" },
"/materials": { page: "/materials" },
"/translation": { page: "/translation" }
}
},
webpack: (config, { dev, defaultLoaders }) => {
config.module.rules.push({
test: /\.scss$/,
use: [
defaultLoaders.babel,
{
loader: styledJsx.loader,
options: {
type: (fileName, options) => options.query.type || "scoped"
}
},
"sass-loader"
]
})
config.module.rules.push({
test: /\.(gif|png|jpe?g)$/i,
type: "asset",
use: "image-webpack-loader"
})
config.module.rules.push({
test: /\.svg$/i,
resourceQuery: /react/,
use: "react-svg-loader"
})
config.module.rules.push({
test: /\.svg$/i,
resourceQuery: { not: [/react/] },
type: "asset",
use: "image-webpack-loader",
generator: {
dataUrl: content => {
content = content.toString()
return svgToMiniDataURI(content)
}
}
})
config.module.rules.push({
test: /\.mdx?$/,
use: [
defaultLoaders.babel,
{
loader: "@mdx-js/loader",
options: mdxOptions
}
]
})
if (dev) {
config.plugins.push(new ESLintPlugin({
extensions: ["js", "jsx"]
}))
}
return config
}
}
export default withBundleAnalyzer({
enabled: process.env.ANALYZE === "true"
})(config)