Created
January 15, 2022 17:10
-
-
Save Tymek/d6967c0add37a0294e0c29f1f89dcc3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { compile } from 'svelte/compiler' | |
/** | |
* @returns {import('vite').Plugin} | |
*/ | |
const vitePluginSvelteDocs = () => { | |
const virtualModuleId = '@virtual:svelte-docs' | |
return { | |
name: 'vite-plugin-svelte-docs', | |
enforce: 'pre', | |
resolveId(id) { | |
if (id === virtualModuleId) { | |
return virtualModuleId | |
} | |
}, | |
load(id) { | |
if (id === virtualModuleId) { | |
const code = `<div>test!!!</div>` | |
const compiled = compile(code) | |
return compiled.js.code | |
} | |
} | |
} | |
} | |
export default vitePluginSvelteDocs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment