Skip to content

Commit 751f8b5

Browse files
aspeddrocknitt
authored andcommitted
upgrade nextjs template
1 parent 25edbfe commit 751f8b5

File tree

11 files changed

+1745
-8238
lines changed

11 files changed

+1745
-8238
lines changed

templates/rescript-template-nextjs/.babelrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

templates/rescript-template-nextjs/next.config.js

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import fs from "fs";
2+
3+
const rescript = JSON.parse(fs.readFileSync("./rescript.json"));
4+
const transpileModules = ["rescript"].concat(rescript["bs-dependencies"]);
5+
6+
const config = {
7+
pageExtensions: ["jsx", "js"],
8+
env: {
9+
ENV: process.env.NODE_ENV,
10+
},
11+
webpack: (config, options) => {
12+
const { isServer } = options;
13+
14+
if (!isServer) {
15+
// We shim fs for things like the blog slugs component
16+
// where we need fs access in the server-side part
17+
config.resolve.fallback = {
18+
fs: false,
19+
path: false,
20+
};
21+
}
22+
23+
// We need this additional rule to make sure that mjs files are
24+
// correctly detected within our src/ folder
25+
config.module.rules.push({
26+
test: /\.m?js$/,
27+
use: options.defaultLoaders.babel,
28+
exclude: /node_modules/,
29+
type: "javascript/auto",
30+
resolve: {
31+
fullySpecified: false,
32+
},
33+
});
34+
35+
return config
36+
}
37+
};
38+
39+
export default {
40+
transpilePackages: transpileModules,
41+
...config,
42+
};

0 commit comments

Comments
 (0)