obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
59 lines (58 loc) • 2.39 kB
text/typescript
/**
* @packageDocumentation
*
* This module provides functionality to build and bundle an Obsidian plugin using esbuild.
* It includes functions to handle the build process based on different build modes (development or production),
* and it sets up various esbuild plugins to preprocess, lint, fix source maps, and copy files to the Obsidian plugins folder.
*/
import type { BuildContext, BuildOptions, Plugin } from 'esbuild';
import { CliTaskResult } from '../CliUtils.mjs';
/**
* Enumeration representing the build modes.
*/
export declare enum BuildMode {
/** Development mode for building the plugin */
Development = 0,
/** Production mode for building the plugin */
Production = 1
}
/**
* Banner text to be included at the top of the generated files.
*/
export declare const banner = "/*\nTHIS IS A GENERATED/BUNDLED FILE BY ESBUILD\nif you want to view the source, please visit the github repository of this plugin\n*/\n";
/**
* Options for building an Obsidian plugin.
*/
export interface BuildObsidianPluginOptions {
/**
* Custom esbuild plugins to be used during the build process.
*/
customEsbuildPlugins?: Plugin[];
/**
* Customizes the esbuild options.
*/
customizeEsbuildOptions?(options: BuildOptions): void;
/**
* The build mode, either Development or Production
*/
mode: BuildMode;
/**
* The folder for Obsidian configuration. Defaults to the `OBSIDIAN_CONFIG_FOLDER` environment variable.
*/
obsidianConfigFolder?: string;
}
/**
* Builds the Obsidian plugin based on the specified mode and configuration folder.
*
* @param options - The parameters for building the plugin.
* @returns A {@link Promise} that resolves to a {@link CliTaskResult} indicating the success or failure of the build.
*/
export declare function buildObsidianPlugin(options: BuildObsidianPluginOptions): Promise<CliTaskResult>;
/**
* Invokes the build process with the provided build context.
*
* @param buildContext - The build context generated by esbuild.
* @param isProductionBuild - A boolean indicating whether the build is a production build.
* @returns A {@link Promise} that resolves to a {@link CliTaskResult} indicating the success or failure of the build.
*/
export declare function invokeEsbuild(buildContext: BuildContext, isProductionBuild: boolean): Promise<CliTaskResult>;