An esbuild plugin that bundles JavaScript/React sources into HTML documents for MML. Supports mml:
import prefix for discovering and bundling additional documents.
npm install --save-dev @mml-io/esbuild-plugin-mml
import { build } from "esbuild";
import { mml } from "@mml-io/esbuild-plugin-mml";
build({
entryPoints: [
"mml:src/playground/index.tsx", // MML document
"src/playground.ts" // World config
],
outdir: "build",
outbase: "src",
bundle: true,
plugins: [mml()],
});
Option | Type | Description | Default |
---|---|---|---|
verbose | boolean | Enable logging | false |
pathPrefix | string | Prefix for import path rewrites | ws:/// |
assetDir | string | Asset output directory | assets |
assetPrefix | string | Asset URL prefix | / |
stripHtmlExtension | boolean | Remove .html from output URLs | false |
Add these type definitions for custom import syntax:
declare module "*.html" {
const value: string;
export default value;
}
declare module "mml:*" {
const value: string;
export default value;
}