viteFunctions
Function: noHmrInkPlugin()
> noHmrInkPlugin(options?): Plugin
Defined in: src/vite/plugins.ts:464
Creates a Vite plugin that:
- Prevents Hot Module Replacement (HMR) for
.inkfiles and instead sends anink-updatedcustom event to the client so that setupInkHmrListener can reload the story. - Transforms
.inkfiles so they can be imported as plain strings. - Optionally generates a virtual module
virtual:pixi-vn-ink(when VitePluginInkOptions.inkGlob is provided) that exports all matched ink file contents as astring[], removing the need to write a manual glob-import helper. - Optionally exports the same matched
.inkfiles as.jsonto a configurable location (when VitePluginInkOptions.inkJsonOutputPattern is provided), together with amanifest.jsonfile for bulk runtime loading withimportPixiVNJson.
Parameters
options?
Optional plugin configuration.
Returns
Plugin
A Vite plugin.
See
https://pixi-vn.com/ink#vite-plugin
Examples
// vite.config.ts – without inkGlob (manual loading)
import { defineConfig } from "vite";
import { vitePluginInk } from "@drincs/pixi-vn-ink/vite";
export default defineConfig({
plugins: [vitePluginInk()],
});// vite.config.ts – with inkGlob (automatic loading via virtual module)
import { defineConfig } from "vite";
import { vitePluginInk } from "@drincs/pixi-vn-ink/vite";
export default defineConfig({
plugins: [vitePluginInk({ inkGlob: "./ink/**/*.ink" })],
});// main.ts
import { importInkText } from "@drincs/pixi-vn-ink";
import { setupInkHmrListener } from "@drincs/pixi-vn-ink/vite-listener";
import inkTexts from "virtual:pixi-vn-ink";
await importInkText(inkTexts);
setupInkHmrListener();// vite.config.ts – generate JSON files in public/ink-json too
import { defineConfig } from "vite";
import { vitePluginInk } from "@drincs/pixi-vn-ink/vite";
export default defineConfig({
plugins: [
vitePluginInk({
inkGlob: "./ink/**/*.ink",
inkJsonOutputPattern: "./public/ink-json/[path][name].json",
}),
],
});// Bulk-load the generated JSON files at runtime
import { importPixiVNJson } from "@drincs/pixi-vn-json/interpreter";
const manifest = (await fetch("/ink-json/manifest.json").then((response) =>
response.json(),
)) as string[];
const stories = await Promise.all(
manifest.map((url) => fetch(url).then((response) => response.json())),
);
await Promise.all(stories.map((story) => importPixiVNJson(story)));