Skip to content

Commit 050282b

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

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 6 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,11 @@ 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: ["**/lib/bs/**", "**/lib/ocaml/**", "**/lib/rescript.lock"],
27+
};
2228
}
2329

2430
// 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)