2.4.0 • Published 2 years ago
@tonyfettes/vite-plugin-melange v2.4.0
vite-plugin-melange
A Vite plugin for Melange.
Features
- Compile Melange source files as part of the build
- Show errors on the commandline and in the browser overlay
- HMR (hot module replacement) with Melange source filenames as module names
Usage
npm install --save-dev vite-plugin-melangevite.config.js:
import { defineConfig } from "vite";
import melangePlugin from "vite-plugin-melange";
export default defineConfig({
plugins: [
melangePlugin({
buildCommand: "opam exec -- dune build",
watchCommand: "opam exec -- dune build --watch",
}),
],
server: {
watch: {
awaitWriteFinish: {
stabilityThreshold: 500,
pollInterval: 20,
},
},
},
});The watch part is configuring chokidar so that the many writes Melange does to its log file appear as a single change (we use the log file to determine when compilation has finished). You may have to tweak it, depending on your project and hardware.
Options
buildCommand: (required) Dune build command. For instance:opam exec -- dune buildwatchCommand: (required) Dune watch command. For instance:opam exec -- dune build --watchbuildContext: (default:"default") Dune build context. The default corresponds to Dune's defaultemitDir: (default:"") directory where themelange.emitstanza is located. It defaults to empty string, which means the project's root folder, as it's the recommended locationbuildTarget: (default:"output")targetfield of themelange.emitstanza. It defines the directory where the JavaScript artifacts will be placed
Build
npm install
npm run build2.4.0
2 years ago