From fc2fb5f052488ebd89ae455d944b54c42a35f315 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Apr 2024 20:44:45 +0200 Subject: [PATCH] Merge pull request #26837 from storybookjs/jeppe/24857-bug-mdx-compilation-breaks-when-using-vitejsplugin-react-swc-and-extending-its-plugins Addon-docs: Fix MDX compilation when using `@vitejs/plugin-react-swc` with plugins (cherry picked from commit d1b4753ba815496c9303573d2b213b71198fec49) --- code/addons/docs/src/preset.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 31248e7af990..4b8811935ec9 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -166,7 +166,8 @@ export const viteFinal = async (config: any, options: Options) => { // add alias plugin early to ensure any other plugins that also add the aliases will override this // eg. the preact vite plugin adds its own aliases plugins.unshift(packageDeduplicationPlugin); - plugins.push(mdxPlugin(options)); + // mdx plugin needs to be before any react plugins + plugins.unshift(mdxPlugin(options)); return config; };