From 3e52440d28b639eb60d9d1ea815081e9b989d0e8 Mon Sep 17 00:00:00 2001 From: Tom Gao Date: Mon, 3 Jun 2024 22:18:19 +0800 Subject: [PATCH] feat: add custom csp option to webview --- README.md | 22 ++++++- README.zh_CN.md | 22 ++++++- examples/vue/vite.config.ts | 6 +- src/index.ts | 117 ++++++++++++++++++++---------------- src/types.ts | 16 ++++- 5 files changed, 127 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index c3dc4db..afc55c4 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ function __getWebviewHtml__( | --- | --- | --- | --- | | recommended | `boolean` | `true` | This option is intended to provide recommended default parameters and behavior. | | extension | [ExtensionOptions](#ExtensionOptions) | | Configuration options for the vscode extension. | -| webview | `boolean` | `false` | Inject [@tomjs/vscode-extension-webview](https://github.com/tomjs/vscode-extension-webview) into vscode extension code and web client code, so that webview can support HMR during the development stage. | +| webview | `boolean` \| `string` \| [WebviewOption](#WebviewOption) | `__getWebviewHtml__` | Inject html code | **Notice** @@ -222,6 +222,16 @@ The `recommended` option is used to set the default configuration and behavior, - The output directory is based on the `build.outDir` parameter of `vite`, and outputs `extension` and `src` to `dist/extension` and `dist/webview` respectively. - Other behaviors to be implemented +**Webview** + +Inject [@tomjs/vscode-extension-webview](https://github.com/tomjs/vscode-extension-webview) into vscode extension code and web client code, so that `webview` can support `HMR` during the development stage. + +- vite serve + - extension: Inject `import __getWebviewHtml__ from '@tomjs/vscode-extension-webview';` above the file that calls the `__getWebviewHtml__` method + - web: Add `