UNPKG

@tomjs/vite-plugin-monaco-editor

Version:

vite plugin for monaco-editor, inject scripts for index.html

77 lines (73 loc) 2.56 kB
import { Plugin } from 'vite'; interface NpmLocal { /** * Same as Vite configuration base option. Default is "/". * @default "/" */ base?: string; /** * Local output directory, default is the same as Vite configuration build.outDir option * @default "dist" */ outDir?: string; /** * Local output path, module URLs will also be replaced with this path. Default is "npm/monaco-editor@{version}" * @default "npm/monaco-editor@{version}" */ path?: string; /** * Whether to copy monaco-editor to output directory. The default value is true when cdn is empty * @default true */ copy?: boolean; } interface ServerConfig { /** * Relative path to node_modules. Default is "/". * @default '/' */ base?: string; } /** * vite plugin options for [monaco-editor](https://github.com/microsoft/monaco-editor) */ interface PluginOptions { /** * `CDN` source type, parameters `version` are taken from the modules configuration. * * When the OS language is `zh_CN` , the default value is `npmmirror`, otherwise it is `jsdelivr`. * * * npmmirror: base will be set to https://registry.npmmirror.com/monaco-editor/{version}/files * * jsdelivr: base will be set to https://cdn.jsdelivr.net/npm/monaco-editor@{version} * * unpkg: base will be set to https://unpkg.com/monaco-editor@{version} * * custom: custom url can be defined * * @default "npmmirror" */ type?: 'npmmirror' | 'unpkg' | 'jsdelivr' | 'custom'; /** * Used in conjunction with the type parameter, sets different urls * * When the OS language is `zh_CN` , the default value is `npmmirror`, otherwise it is `jsdelivr`. * * * npmmirror: https://registry.npmmirror.com/monaco-editor/{version}/files * * jsdelivr: https://cdn.jsdelivr.net/npm/monaco-editor@{version} * * unpkg: https://unpkg.com/monaco-editor@{version} * * custom: custom url */ url?: string; /** * Local mode or more configurations for local mode. Default is false. * @default false */ local?: boolean | NpmLocal; /** * Configuration when vite command is serve */ serve?: ServerConfig; } /** * use vite plugin for [monaco-editor](https://github.com/microsoft/monaco-editor) */ declare function useMonacoEditorPlugin(options?: PluginOptions): Plugin[]; export { type NpmLocal, type PluginOptions, type ServerConfig, useMonacoEditorPlugin as default, useMonacoEditorPlugin };