You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{mergeConfig,Plugin}from'vite'importfsfrom'fs'importpathfrom'path'functioncustomResolverPlugin(){return{name: 'custom-resolver',resolveId(source){if(source.startsWith('@theme/')){constpackageName=source.slice(7)// Remove '@theme/'constsrcPath=path.resolve(__dirname,`src/theme/${packageName}`)// Check if the module exists in 'src/theme'if(fs.existsSync(srcPath)){returnsrcPath}return`@docusaurus/theme-classic/lib/theme/${packageName}`}},}satisfiesPlugin}
Unfortunately it does not work. I get:
6:52:42 PM [vite] Pre-transform error: Failed to load url @docusaurus/theme-classic/lib/theme/Navbar (resolved id: @docusaurus/theme-classic/lib/theme/Navbar) in /Users/levinkeller/coding/levino/levinkeller.de/shipyard/base/components/Header.tsx. Does the file exist?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a written a plugin like so:
Unfortunately it does not work. I get:
However stuff like
in the vite config, it works fine.
If I use
as a return value in the plugin, vite resolves the file, but that creates issues of its own (suddenly vite is unable to transpile the .jsx content).
I want to implement some kind of import hierarchy to use the swizzling from docusaurus in my other (astro) app.
Thanks for help!
Beta Was this translation helpful? Give feedback.
All reactions