forked from VulcanJS/vulcan-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
80 lines (69 loc) · 2.63 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
// Use @next/mdx for a basic MDX support.
// See the how Vulcan Next docs are setup with next-mdx-remote
// which is more advanced (loading remote MD, supporting styling correctly etc.)
const withMDX = require("@next/mdx")({ extension: /\.mdx?$/ });
// Custom config from vulcan-next
const { extendNextConfig } = require("./packages/@vulcanjs/next-config");
const withPkgInfo = require("./.vn/nextConfig/withPkgInfo");
const withI18n = require("./.vn/nextConfig/withI18n");
const {
vnRedirects,
vnRewrites,
} = require("./.vn/nextConfig/redirectsAndRewrites");
const flowRight = require("lodash/flowRight");
const debug = require("debug")("vn:next");
// @see https://nextjs.org/docs/api-reference/next.config.js/runtime-configuration
module.exports = (phase, { defaultConfig }) => {
let extendedConfig;
extendedConfig = extendNextConfig(defaultConfig);
extendedConfig.env = {
NEXT_PUBLIC_IS_USING_DEMO_DATABASE: !!(process.env.MONGO_URI || "").match(
/lbke\-demo/
),
NEXT_PUBLIC_IS_USING_LOCAL_DATABASE: !!(process.env.MONGO_URI || "").match(
/localhost/
),
};
// Enable Webpack analyzer
if (process.env.ANALYZE && process.env.ANALYZE !== "false") {
const debug = require("debug")("webpack");
debug("Enabling Webpack bundle analyzer");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
extendedConfig = withBundleAnalyzer(extendedConfig);
}
// Disable linting during build => the linter may have optional dev dependencies
// (eslint-plugin-cypress) that wont exist during prod build
// You should lint manually only
extendedConfig.eslint = {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
};
// To support markdown import
extendedConfig.pageExtensions = ["js", "jsx", "md", "mdx", "ts", "tsx"];
extendedConfig = flowRight([
withPkgInfo,
withMDX,
withI18n,
// add other wrappers here
])(extendedConfig);
extendedConfig.redirects = async () => {
// learn offline vs online
return [...(await vnRedirects())];
};
extendedConfig.rewrites = async () => {
// rewrite Vulcan Next page to "/vn"
return [...(await vnRewrites())];
};
extendedConfig.experimental = {};
/*{
// @see https://github.com/isaachinman/next-i18next/issues/1202#issuecomment-871233853
// @see https://github.com/vercel/next.js/issues/24700
// Remove after update to Next 11.4+
//outputFileTracing: true,
};*/
debug("Extended next config FINAL " + JSON.stringify(extendedConfig));
return extendedConfig;
};