A Vite plugin for Melange.
- 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
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",
}),
]
});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 (relative to Vite root) where themelange.emitstanza is located. It defaults to the current directory, which is the recommended locationbuildTarget: (default:"output")targetfield of themelange.emitstanza. It defines the directory where the JavaScript artifacts will be placedduneDir: (default:".") Directory (relative to Vite root) where Dune is running (can be used for instance ifdune-projectis in the parent directory). You may also need to add it toserver.fs.allow.
npm install
npm run build