Skip to content

Commit 7048f84

Browse files
fix: update vite + nextjs config to ignore rescript build artifacts
1 parent 56a8c99 commit 7048f84

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "fs";
2+
import path from "path";
23

34
const rescript = JSON.parse(fs.readFileSync("./rescript.json"));
45
const transpileModules = ["rescript"].concat(rescript["bs-dependencies"]);
@@ -19,6 +20,15 @@ const config = {
1920
fs: false,
2021
path: false,
2122
};
23+
config.watchOptions = {
24+
...config.watchOptions,
25+
// We ignore ReScript build artifacts to avoid unnecessarily triggering HMR on incremental compilation
26+
ignored: [
27+
path.join(import.meta.dirname, "lib", "bs"),
28+
path.join(import.meta.dirname, "lib", "ocaml"),
29+
path.join(import.meta.dirname, "lib", "rescript.lock"),
30+
],
31+
};
2232
}
2333

2434
// We need this additional rule to make sure that mjs files are

templates/rescript-template-vite/vite.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react";
3-
import tailwindcss from '@tailwindcss/vite';
3+
import tailwindcss from "@tailwindcss/vite";
44

55
// https://vitejs.dev/config/
66
export default defineConfig({
@@ -10,4 +10,10 @@ export default defineConfig({
1010
include: ["**/*.res.mjs"],
1111
}),
1212
],
13+
server: {
14+
watch: {
15+
// ignore ReScript build artifacts
16+
ignored: ["**/lib/bs/**", "**/lib/ocaml/**", "**/lib/rescript.lock"],
17+
},
18+
},
1319
});

0 commit comments

Comments
 (0)