# live-svg

> Live svg reloader from any editor

Latest version **1.0.1** (published 2017-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install live-svg
pnpm add live-svg
yarn add live-svg
bun add live-svg
```

Provides the command `live-svg`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-09-26 |
| First published | 2017-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Mathieu PATUREL |
| Maintainers | math2001 |

## Links

- npm: https://www.npmjs.com/package/live-svg
- Repository: https://github.com/math2001/live-svg
- Homepage: https://github.com/math2001/live-svg#readme
- Issues: https://github.com/math2001/live-svg/issues
- npm.io page: https://npm.io/package/live-svg

## Dependencies (4)

- [opn](https://npm.io/package/opn.md) ^5.1.0
- [express](https://npm.io/package/express.md) ^4.15.4
- [chokidar](https://npm.io/package/chokidar.md) ^1.7.0
- [socket.io](https://npm.io/package/socket.io.md) ^2.0.3

## Recent versions

- 1.0.1 (latest) — 2017-09-26
- 1.0.0 — 2017-09-20
- 0.1.1 — 2017-09-17

## README

# `live-svg`

`live-svg` is a simple script that will run a server to serve `.svg` files and
update them live as soon as you save.

It doesn't reload the entire page, it just updates the svg codes in the browser.

## Installation

```
$ npm install -g live-svg
```

Or

```
$ yarn global add live-svg
```

## Demo

![demo of live-svg](demo.gif)

The editor is VIM on wsltty. To increase/decrease numbers in VIM, just press
<kbd>ctrl+a</kbd> and <kbd>ctrl+x</kbd>.

## Usage

Start `live-svg` by just running it from your favorite terminal.

Open your browser at <http://localhost:3663> followed by the
relative path to the svg(s) you want to preview.

```
- root
    - subdirectory
        - mysvg.svg
```

So, if you run `live-svg` from root, you'll need to open
<http://localhost:6336/subdirectory/mysvg.svg>

It'll automatically watch the files that are open, and reload them as soon as you
save.

It makes learning to write SVG by hand or simply editing one much easier.

There are different options:

#### `--port <int>`

The port to run the server on. By default it's `6336`, because 336 because it's
the sum of the ASCII values of each letter in `svg`, and an extra 6 at the start
because [palindromes number][] are cool :smile:

#### `--cwd`

By default, it's the where you currently are. But, using the previous example, if
you ran: `live-svg --cwd subdirectory/`, you would've had to open
<http://localhost:6336/mysvg.svg>

#### `--auto-exit`

Automatically exit as soon as every tab previewing svgs on the server created by
live-svg in every browser.

Basically, if you close the last svg in the browser, this program will exit.

#### The rest?

Every other arguments will be considered as file names, and will automatically be
open in the browser by default.

### Absolute live

If you want to get browser be updated as soon as you make one modification, that
means you have to *save* as soon as you make one modification.

Therefore, it depends on your editors, but it shouldn't be too hard.

#### Sublime Text

Just use the plugin [auto-save](https://packagecontrol.io/packages/auto-save).

#### Vim

```vim
:autocmd TextChanged,TextChangedI <buffer> write<CR>
```

I recommend you bind it to a shortcut, for example

```vim
nnoremap <leader>l :autocmd TextChanged,TextChangedI <buffer> write<CR>
```

(feel free to contribute to add your favorite editor)

[Palindromes number]: https://en.wikipedia.org/wiki/Palindromic_number

---
_Source: https://npm.io/package/live-svg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
