1 | import { Plugin } from 'vite';
|
2 | import { Options } from 'tsup';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | interface ExtensionOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | 'watch' | 'onSuccess' | 'skipNodeModulesBundle'> {
|
8 | |
9 |
|
10 |
|
11 |
|
12 | entry?: string;
|
13 | |
14 |
|
15 |
|
16 |
|
17 | outDir?: string;
|
18 | |
19 |
|
20 |
|
21 | format?: 'cjs';
|
22 | |
23 |
|
24 |
|
25 | skipNodeModulesBundle?: boolean;
|
26 | |
27 |
|
28 |
|
29 | onSuccess?: () => Promise<void | undefined | (() => void | Promise<void>)>;
|
30 | }
|
31 | /**
|
32 | * vite plugin options.
|
33 | */
|
34 | interface PluginOptions {
|
35 | /**
|
36 | * Recommended switch. Default is true.
|
37 | * if true, will have the following default behavior:
|
38 | * * will change the extension/webview outDir to be parallel outDir;
|
39 | * eg. if vite build.outDir is 'dist', will change extension/webview to 'dist/extension' and 'dist/webview'
|
40 | * @default true
|
41 | */
|
42 | recommended?: boolean;
|
43 | /**
|
44 | * Inject [@tomjs/vscode-extension-webview](https:
|
45 | *
|
46 | * * vite serve
|
47 | * * extension: Inject `import __getWebviewHtml__ from '@tomjs/vscode-extension-webview';` above the file that calls the `__getWebviewHtml__` method
|
48 | * * web: Add `<script>` tag to index.html and inject `@tomjs/vscode-extension-webview/client` code
|
49 | * * vite build
|
50 | * * extension: Inject `import __getWebviewHtml__ from '@tomjs/vite-plugin-vscode-inject';` above the file that calls the `__getWebviewHtml__` method
|
51 | *
|
52 | * If is string, will set inject method name. Default is '__getWebviewHtml__'.
|
53 | *
|
54 | * @example
|
55 | * extension file
|
56 | * ```ts
|
57 | *function setupHtml(webview: Webview, context: ExtensionContext) {
|
58 | * if (process.env.VITE_DEV_SERVER_URL) {
|
59 | * return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
|
60 | * }
|
61 | * return __getWebviewHtml__(webview, context);
|
62 | *}
|
63 | * ```
|
64 | * webview client
|
65 | * ```html
|
66 | * <html>
|
67 | * <head>
|
68 | * <script>inject code</script>
|
69 | * </head>
|
70 | * </html>
|
71 | * ```
|
72 | */
|
73 | webview?: boolean | string;
|
74 | |
75 |
|
76 |
|
77 | extension?: ExtensionOptions;
|
78 | }
|
79 |
|
80 | declare function useVSCodePlugin(options?: PluginOptions): Plugin[];
|
81 |
|
82 | export { useVSCodePlugin as default, useVSCodePlugin };
|
83 |
|
\ | No newline at end of file |