obsidianPluginRollup
Creates a rollup plugin that builds an Obsidian plugin.
What it does, each only when the consumer’s config has not said otherwise:
inputissrc/main.ts. - The output is one CommonJSmain.jsindist/build(dist/devin watch mode), with dynamic imports inlined, the generated-file banner, and an inline source map in development.
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 before the first write, 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.
TypeScript, dependency resolution and minification stay the consumer’s choice of rollup plugins, as they would be without this one. The build features (ObsidianPluginFeatureOptions) are the plugin’s:
framework: 'react' | 'preact'sets rollup’sjsxoption to the automatic runtime (unless set), and the TypeScript plugin reads the same from the toolkit’s tsconfig preset. -framework: 'solid' | 'svelte'compiles the components with the toolkit’s shared transforms, and'vue'addsunplugin-vue. - Any framework replacesprocess.env.NODE_ENV(and Vue’s feature flags) in the bundled code. -stylescompiles every stylesheet itself (PostCSS, Tailwind, CSS modules), so rollup needs no CSS plugin; leave it out.styles: {}compiles plain CSS. -wasmimports a.wasmmodule as its bytes.
Import:
import { obsidianPluginRollup } from '@mnaoumov/obsidian-dev-toolkit/bundlers/rollup';Signature:
function obsidianPluginRollup(options: ObsidianPluginRollupOptions): InputPluginOption[]Parameters:
| Parameter | Type | Description |
|---|---|---|
options |
ObsidianPluginRollupOptions | The ObsidianPluginRollupOptions. |
Returns: InputPluginOption[] — The rollup plugins, which rollup takes as one entry of its plugins.
Links to this page: