obsidianPluginVite
Creates a vite plugin that builds an Obsidian plugin.
What it does, each only when the consumer’s config has not said otherwise:
build.libbuildssrc/main.tsas one CommonJSmain.js, with its CSS instyles.css. -build.outDirisdist/build(dist/devin development). -build.minifyis on in production only, andbuild.sourcemapis inline in development only. - Every asset is inlined, because an Obsidian release shipsmain.jsandstyles.cssand nothing else. - Dynamic imports are inlined intomain.js, and the generated-file banner heads it.
And always: Obsidian’s own modules (obsidian, electron, CodeMirror, Lezer) and the Node builtins are external beside the consumer’s own external, the output folder is emptied once before the first write (build.emptyOutDir is turned off, since this plugin does it), every emitted CSS file ends up in styles.css, manifest.json (and in development .hotreload) is copied beside it, and a development build is deployed into the vault named by OBSIDIAN_CONFIG_FOLDER.
The build features (ObsidianPluginFeatureOptions):
framework: 'react' | 'preact'setsoxc.jsxto the automatic runtime (unless set). -framework: 'solid' | 'svelte'compiles the components with the toolkit’s shared transforms, and'vue'addsunplugin-vue. - Any framework definesprocess.env.NODE_ENV(and Vue’s feature flags), which a library build leaves alone. -styles.postcssandstyles.tailwindsetcss.postcss(unless set); vite scopes*.module.cssitself, sostyles.cssModuleschanges nothing here. -wasmimports a.wasmmodule as its bytes.
Import:
import { obsidianPluginVite } from '@mnaoumov/obsidian-dev-toolkit/bundlers/vite';Signature:
function obsidianPluginVite(options: ObsidianPluginViteOptions): PluginOption[]Parameters:
| Parameter | Type | Description |
|---|---|---|
options |
ObsidianPluginViteOptions | The ObsidianPluginViteOptions. |
Returns: PluginOption[] — The vite plugins, which vite takes as one entry of its plugins.
Links to this page: