Skip to content

Instantly share code, notes, and snippets.

@Tymek
Created January 15, 2022 17:10
Show Gist options
  • Save Tymek/d6967c0add37a0294e0c29f1f89dcc3a to your computer and use it in GitHub Desktop.
Save Tymek/d6967c0add37a0294e0c29f1f89dcc3a to your computer and use it in GitHub Desktop.
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