Git Product home page Git Product logo

svelte-inspector's Introduction

Svelte inspector

Development helper for inspecting and opening svelte components in your editor.

Installation

npm i --save-dev svelte-inspector

Preparation

Make sure that dev property in your svelte's compiler (loader, plugin, etc...) options have set as true. https://svelte.dev/docs#svelte_compile

Usage

  1. Import svelte-inspector package and call the function at the top of your bundle configuration file (ex. rollup, webpack, parcel, etc...):
import startInspector from 'svelte-inspector';
startInspector(/*config*/);

or

const startInspector = require('svelte-inspector');
startInspector(/*config*/);
  1. Add this code in the index file of your client code: (Don't forget to cut this code in the final production bundle)
const script = document.createElement('script');
script.src = 'http://0.0.0.0:5001/start';
document.body.appendChild(script);

or this code in the bottom of body tag in index.html

<script type="application/javascript" src="http://0.0.0.0:5001/start"></script>
  1. Open your web app and press 'O' (configurable) for toggling the inspecting mode.

  2. Move cursor to the element and press 'A' to open element's component in the editor.

Configuration

{
  // Code for the key that activates inspecting mode
  // default 79 - means for 'O'
  activateKeyCode: 79;
  // Code for the key that opens file in editor
  // default 65 - means for 'A'
  openFileKeyCode: 65;
  // Default editor to open inpspected components
  // default 'code' - means for 'VS Code'
  // Allowed values: 'sublime', 'atom', 'code', 'webstorm', 'phpstorm', 'idea14ce', 'vim', 'emacs', 'visualstudio'
  editor: 'code';
  // Inspector's color
  color: '#009688';
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.