forked from ryyppy/rescript-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
46 lines (41 loc) · 1.14 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
const bsconfig = require('./bsconfig.json');
const fs = require("fs");
const transpileModules = ["rescript"].concat(bsconfig["bs-dependencies"]);
const withTM = require("next-transpile-modules")(transpileModules);
const isWebpack5 = true;
const config = {
target: "serverless",
pageExtensions: ["jsx", "js"],
env: {
ENV: process.env.NODE_ENV,
},
webpack: (config, options) => {
const { isServer } = options;
if (isWebpack5) {
if (!isServer) {
// We shim fs for things like the blog slugs component
// where we need fs access in the server-side part
config.resolve.fallback = {
fs: false,
path: false,
};
}
// We need this additional rule to make sure that mjs files are
// correctly detected within our src/ folder
config.module.rules.push({
test: /\.m?js$/,
use: options.defaultLoaders.babel,
exclude: /node_modules/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
}
});
}
return config
},
future: {
webpack5: isWebpack5
}
};
module.exports = withTM(config);