shadowMdx
Creates the plugin that compiles MDX to ShadowJS components.
Creates the plugin that compiles MDX to ShadowJS components. It runs before Vite's own handling (enforce: "pre"), so Vite
never sees MDX or JSX. A file is compiled for the browser, or for the server in an SSR build; a syntax error in the MDX is
reported with its file, line and column. Hot updates reload the page: an MDX file has no component state worth keeping.
Import#
ts
import { shadowMdx } from "@shadow-js/vite/mdx";
Signature#
ts
function shadowMdx(options: ShadowMdxOptions = {}): Plugin
Parameters#
| Name | Description |
|---|---|
options |
Which files, the remark, rehype and recma plugins, and the MDX compiler. |
Returns#
A Vite plugin named shadowjs-mdx.
Throws#
- TypeError when
includeorexcludeis not aRegExp, orpluginsis not a list of valid compiler plugins.
Examples#
ts
// vite.config.ts
import { shadow } from "@shadow-js/vite";
import { shadowMdx } from "@shadow-js/vite/mdx";
import remarkFrontmatter from "remark-frontmatter";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
export default {
plugins: [
shadowMdx({ remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter] }),
shadow(),
],
};