• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run your web app inside VS Code

VS Code Live Frame

Run your web application inside VS Code.

Why would you want to do that?

You're developing a web application, and you've got some kind of a live/hot reloading setup. Instead of switching between your editor and a browser, with Live Frame you can see your changes without leaving VS Code.

Or, perhaps, you're streaming or recording a screen cast, and you just want everything nicely in one window. Whatever your reasons, we're not here to judge.

Demo

How to use it

  1. Install Live Frame from the VS Code Marketplace.
  2. Start your local development server
  3. Run (Cmd+Shift+P) command Live Frame: Open
  4. Follow the displayed configuration instructions.

Extension Settings

Add the following to your User or Workspace settings. Given that your app's development URL is probably project specific, Workspace settings may make more sense.

{
  // Required: The website to display
  "liveFrame.url": "http://localhost:3000",

  // Optional: Title for the pane tab heading
  "liveFrame.title": "Local Development",

  // Optional: Which pane to open the frame in
  "liveFrame.pane": "Beside"
}

If you have a fast hot reloading setup, you can turn on VS Code's Auto Save on a short delay when you need an extra blazing feedback loop.

{
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 50,
}

Known Limitations

Because of the way Live Frame renders your site in an iframe-inside-webview, there are a couple of limitations.

Your site needs to be able to run in an iframe

If your website prevents itself being loaded in an iframe e.g. via X-Frame-Options or Content-Security-Policy, it won't work inside Live Frame.

This should not be an issue for most development setups, but if it is, try VSCode Browser Preview instead.

Dev tools work, but element selector doesn't

You can open dev tools by running (Cmd+Shift+P) the Open WebView Developer Tools command. However, the point and click element selector doesn't select element inside the iframe.

Command key combinations (Copy, Paste, Select all...) are disabled

This is a known issue in VS Code.

As a workaround, you can send your keystrokes to the extension using postMessage, and we'll forward them to VS Code for you. Just add the following somewhere in your application code:

if (window.parent !== window) {
  // If using TypeScript, next line should be:
  // let listener = (e: KeyboardEvent) =>
  let listener = (e) =>
    window.parent.postMessage(
      JSON.stringify({
        altKey: e.altKey,
        code: e.code,
        ctrlKey: e.ctrlKey,
        isComposing: e.isComposing,
        key: e.key,
        location: e.location,
        metaKey: e.metaKey,
        repeat: e.repeat,
        shiftKey: e.shiftKey,
      }),
      "*"
    );

  if (!window.hasOwnProperty("keyhookInstalled")) {
    // If using TypeScript, next line should be:
    // (window as any).keyhookInstalled = true;
    window.keyhookInstalled = true;
    window.addEventListener("keydown", listener);
  }
}

If you can think of a better solution (to fix the keyboard issue, or that doesn't involve using an iframe at all), see Contributing.

Infrequently Asked Questions

Which bundlers, dev servers etc. does Live Frame support?

All of them. Livereload, webpack, vite, servor, whatever angular people use... shouldn't matter. If yours doesn't work, double check it's not your own fault, and open an issue.

Wait, didn't this exist before?

Sort of. Browser Preview embeds a headless Chrome, which is awesome, but also very resource intensive and kept crashing my VS Code. Then there are about a dozen extensions that live reload HTML in various ways, but if you're working with a web application with a build step, they're no use.

Live Frame takes a simple but lightweight route and uses a VS Code Webview pane, and inside it renders your app in a full-screen iframe. You can see the full implementation in extension.ts.

So is this exactly like a regular Chrome environment?

Not really. It's an embedded Electron webview with known limitations, and I'm sure many other minor differences to a full browser.

Use at your own peril during development, not for acceptance testing!

Release Notes

0.1.1

Add workaround for keyboard binding issue.

0.1.0

Initial release.

Contributing

Pull requests are welcome! For anything that significantly grows the scope of this project or complicates its maintenance, please open an issue to discuss first.

Local development

Install dependencies with yarn, and run the project with Run > Start Debugging from within VS Code.

License

MIT

More Repositories

1

git-notify

๐Ÿ™‰ ๐Ÿ“ฃ Communicate important updates to your team via git commit messages
TypeScript
1,346
star
2

jest-clean-console-reporter

A Jest Reporter to group, hide and prettify spammy console warnings
JavaScript
541
star
3

vscode-hacker-typer

Great for live coding presentations, impressing your friends, or just trying to look busy at work.
TypeScript
453
star
4

react-native-chat-tutorial

A step-by-step tutorial to create your own Chat app with React Native
JavaScript
277
star
5

css-properly

Write CSS Properly ๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿง
JavaScript
235
star
6

react-native-reversed-flat-list

[DEPRECATED] A reversed React Native FlatList, useful for creating performant bottom-anchored lists for chats and whatnot
JavaScript
136
star
7

NaNoWriMo

Wallet - A Novel for National Novel Writing Month 2018
JavaScript
28
star
8

is-it-over

It's so over. No wait, we're back.
TypeScript
27
star
9

redux-offline-example

โ˜• Something brewin' here. Come back next week.
JavaScript
19
star
10

react-native-animated-playground

Shared transitions with React Native Animated
JavaScript
17
star
11

react-native-snap-demo

A "Snapchat" demo app for React Native for Beginners course
JavaScript
13
star
12

cloudflare-pages-react-sqlite-starter

Vite on Cloudflare Pages
TypeScript
12
star
13

cycle-react-native-example

Sample application for using Cycle.js with React Native (CycleConf 2016)
JavaScript
10
star
14

react-native-training-chat-server

A client library for a chat server to be used in React Native training
JavaScript
9
star
15

jevakallio.dev

My personal website
HTML
8
star
16

hello-worker

Experimenting with CloudFlare Workers and Durable Objects. Nothing to see here.
Shell
6
star
17

SharedTransitions

Experiments with React Native shared element transitions
JavaScript
6
star
18

crna-pull-request-preview

Deprecated. Go to: https://github.com/FormidableLabs/appr
JavaScript
6
star
19

react-derivable-tools

Utilities for using DerivableJS with React
JavaScript
6
star
20

needly

A tiny JavaScript dependency injector / service locator
JavaScript
4
star
21

habbit

Old habits die hard. These birds just keep dying.
TypeScript
4
star
22

jargon-of-the-day

3
star
23

react-native-snap-camera

A Camera component for React Native For Beginners course
JavaScript
2
star
24

restless-london

RESTless London Meetup website
JavaScript
2
star
25

victory-composed

Ready-made composed Victory components
JavaScript
2
star
26

react-native-snap-drag

Building blocks for React Native For Beginners course
JavaScript
2
star
27

foamblog

Open Foam
HTML
1
star
28

hidden-helsinki

JavaScript
1
star
29

party-daemons

Partykit Implementation of AI Daemons
TypeScript
1
star
30

foam-launcher

Just prototyping. Nothing to see here
JavaScript
1
star
31

pepperoni-hackathon-app

JavaScript
1
star
32

partyflags

WIP
TypeScript
1
star
33

partykit-onfetch-routing

Example of using PartyKit onFetch to do dynamic routing to rooms using cookies
TypeScript
1
star
34

kallio-prototype

Protoype for Helsinki-based city adventure game
JavaScript
1
star