diff options
Diffstat (limited to 'packages/integrations/mdx/src/index.ts')
-rw-r--r-- | packages/integrations/mdx/src/index.ts | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index d07913ede..bd3d50c86 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -1,39 +1,39 @@ -import type { AstroIntegration } from 'astro'; import mdxPlugin from '@mdx-js/rollup'; +import type { AstroIntegration } from 'astro'; export default function mdx(): AstroIntegration { return { - name: '@astrojs/mdx', - hooks: { - 'astro:config:setup': ({ updateConfig, addPageExtension, command }: any) => { - addPageExtension('.mdx'); - updateConfig({ - vite: { - plugins: [ - { - enforce: 'pre', - ...mdxPlugin({ - jsx: true, - jsxImportSource: 'astro', - // Note: disable `.md` support - format: 'mdx', - mdExtensions: [] - }) - }, - command === 'dev' && { - name: '@astrojs/mdx', - transform(code: string, id: string) { - if (!id.endsWith('.mdx')) return; - // TODO: decline HMR updates until we have a stable approach - return `${code}\nif (import.meta.hot) { + name: '@astrojs/mdx', + hooks: { + 'astro:config:setup': ({ updateConfig, addPageExtension, command }: any) => { + addPageExtension('.mdx'); + updateConfig({ + vite: { + plugins: [ + { + enforce: 'pre', + ...mdxPlugin({ + jsx: true, + jsxImportSource: 'astro', + // Note: disable `.md` support + format: 'mdx', + mdExtensions: [], + }), + }, + command === 'dev' && { + name: '@astrojs/mdx', + transform(code: string, id: string) { + if (!id.endsWith('.mdx')) return; + // TODO: decline HMR updates until we have a stable approach + return `${code}\nif (import.meta.hot) { import.meta.hot.decline(); - }` - } - } - ] - } - }) - } - } - } + }`; + }, + }, + ], + }, + }); + }, + }, + }; } |