Skip to content

How to run/embed VSCode for Web #265502

@progrium

Description

@progrium

I feel like this should be documented somewhere. Since the switch to ES imports, I haven't found a good example to start VSCode on a web page, but I figured it out. This is the rest of the answer to #136361 and part of the answer to #135856, neither of which I can comment on.

A complete Gist including how to build VSCode for Web minimally is here, but this is what I hadn't been able to find:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./vscode/out/vs/workbench/workbench.web.main.internal.css" />
</head>
<body style="margin:0;overflow:hidden;">
<script>
    const baseUrl = new URL('/vscode', window.location.origin).toString();
    globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
</script>
<script src="./vscode/out/nls.messages.js"></script>
<script type="module">
    import { create } from './vscode/out/vs/workbench/workbench.web.main.internal.js';
    create(document.body, {
        "configurationDefaults": {
            "window.commandCenter": false,
            "workbench.secondarySideBar.defaultVisibility": "hidden",
            "workbench.layoutControl.enabled": false,
            "workbench.startupEditor": "none",
            "workbench.tips.enabled": false,
            "workbench.welcomePage.walkthroughs.openOnInstall": false
        }
    });
</script>
</body>
</html>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions