generated from ryyppy/rescript-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.mjs
51 lines (44 loc) · 1.22 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
import * as fs from 'fs';
import bsconfig from './bsconfig.json' assert {type: 'json'};
import nextTranspileModule from 'next-transpile-modules'
const transpileModules = ["rescript"].concat(bsconfig["bs-dependencies"]);
const withTM = nextTranspileModule(transpileModules);
const isWebpack5 = true;
/**
* @type {import('next').NextConfig}
*/
const config = {
pageExtensions: ["jsx", "js", "mjs"],
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
}
};
export default withTM(config);