rebornix/vscode-webview-react
소개
Create React App starter in VSCode Webview.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalVSCode Webview React
This project was bootstrapped with
The webview API allows extensions to create customizable views within VSCode. Single Page Application frameworks are perfect fit for this use case. However, to make modern JavaScript frameworks/toolchains appeal to VSCode webview API's security best practices requires some knowledge of both the bundling framework you are using and how VSCode secures webview. This project aims to provide an out-of-box starter kit for Create React App and TypeScript in VSCode's webview.
Development
Run following commands in the terminal
yarn install --ignore-engines
yarn run build
And then press F5, in Extension Development Host session, run Start React Webview command from command palette.
Under the hood
Things we did on top of Create React App TypeScript template
- We inline
index.htmlcontent inext-src/extension.tswhen creating the webview - We set strict security policy for accessing resources in the webview.
- Only resources in
/buildcan be accessed - Onlu resources whose scheme is
vscode-resourcecan be accessed.
- Only resources in
- For all resources we are going to use in the webview, we change their schemes to
vscode-resource - Since we only allow local resources, absolute path for styles/images (e.g.,
/static/media/logo.svg) will not work. We add a.envfile which setsPUBLIC_URLto./and after bundling, resource urls will be relative. - We add baseUrl
<base href="${vscode.Uri.file(path.join(this._extensionPath, 'build')).with({ scheme: 'vscode-resource' })}/">and then all relative paths work.
Limitations
Right now you can only run production bits (yarn run build) in the webview, how to make dev bits work (webpack dev server) is still unknown yet. Suggestions and PRs welcome !
관련 프로젝트 살펴보기
불러오는 중…