UNPKG

2.56 kBTypeScriptView Raw
1import { Plugin } from 'vite';
2
3interface NpmLocal {
4 /**
5 * Same as Vite configuration base option. Default is "/".
6 * @default "/"
7 */
8 base?: string;
9 /**
10 * Local output directory, default is the same as Vite configuration build.outDir option
11 * @default "dist"
12 */
13 outDir?: string;
14 /**
15 * Local output path, module URLs will also be replaced with this path. Default is "npm/monaco-editor@{version}"
16 * @default "npm/monaco-editor@{version}"
17 */
18 path?: string;
19 /**
20 * Whether to copy monaco-editor to output directory. The default value is true when cdn is empty
21 * @default true
22 */
23 copy?: boolean;
24}
25interface ServerConfig {
26 /**
27 * Relative path to node_modules. Default is "/".
28 * @default '/'
29 */
30 base?: string;
31}
32/**
33 * vite plugin options for [monaco-editor](https://github.com/microsoft/monaco-editor)
34 */
35interface PluginOptions {
36 /**
37 * `CDN` source type, parameters `version` are taken from the modules configuration.
38 *
39 * When the OS language is `zh_CN` , the default value is `npmmirror`, otherwise it is `jsdelivr`.
40 *
41 * * npmmirror: base will be set to https://registry.npmmirror.com/monaco-editor/{version}/files
42 * * jsdelivr: base will be set to https://cdn.jsdelivr.net/npm/monaco-editor@{version}
43 * * unpkg: base will be set to https://unpkg.com/monaco-editor@{version}
44 * * custom: custom url can be defined
45 *
46 * @default "npmmirror"
47 */
48 type?: 'npmmirror' | 'unpkg' | 'jsdelivr' | 'custom';
49 /**
50 * Used in conjunction with the type parameter, sets different urls
51 *
52 * When the OS language is `zh_CN` , the default value is `npmmirror`, otherwise it is `jsdelivr`.
53 *
54 * * npmmirror: https://registry.npmmirror.com/monaco-editor/{version}/files
55 * * jsdelivr: https://cdn.jsdelivr.net/npm/monaco-editor@{version}
56 * * unpkg: https://unpkg.com/monaco-editor@{version}
57 * * custom: custom url
58 */
59 url?: string;
60 /**
61 * Local mode or more configurations for local mode. Default is false.
62 * @default false
63 */
64 local?: boolean | NpmLocal;
65 /**
66 * Configuration when vite command is serve
67 */
68 serve?: ServerConfig;
69}
70
71/**
72 * use vite plugin for [monaco-editor](https://github.com/microsoft/monaco-editor)
73 */
74declare function useMonacoEditorPlugin(options?: PluginOptions): Plugin[];
75
76export { type NpmLocal, type PluginOptions, type ServerConfig, useMonacoEditorPlugin as default, useMonacoEditorPlugin };