Loomguides

Advanced Vite setup

Import the plugin by its bare specifier, and keep it out of a Vite config that serves another React app.

Vite integration covers the setup that works. This page covers two ways it breaks once it moves into a real workspace.

Always import the plugin by its bare specifier

Import @loom-dev/preview/vite and nothing else:

// correct
import { loomPreview } from "@loom-dev/preview/vite";
// broken — do not do this
import { loomPreview } from "../loom/packages/preview/src/vite.ts";

The plugin finds the modules it aliases relative to its own file. A path import lets Vite bundle the plugin into a temporary file inside your project, which moves that anchor. The config still loads, and the build fails later with an error that looks unrelated:

[commonjs--resolver] Failed to resolve entry for package "@loom-dev/layout".
The package may have incorrect main/module/exports specified in its package.json.

Don’t merge this into an app that also uses React

loomPreview() changes the whole Vite config it lives in, not just your Roblox files:

  • It aliases bare react, react/jsx-runtime and react/jsx-dev-runtime to loom’s own React 18.
  • It sets esbuild.jsx: "automatic" for every module.

Add it to an existing React web app’s config and that app gets loom’s React 18. A React 19 app breaks, and alongside @vitejs/plugin-react you get two JSX transforms fighting.

Keep the preview in its own Vite instance. Any of these works:

  • A dedicated preview app in your workspace, with its own vite.config.ts and dependencies. A config holding only loomPreview() is enough.
  • No Vite project at all. loom preview and loom build ignore your project’s Vite config, so they can’t collide with it.
  • Mounted inside your app’s dev server with loom-dev/embed. The gallery still runs in its own Vite instance, so the two module graphs never meet.

When something breaks

Every error string, including the runtime ones, is in Troubleshooting.