# unv

> Universal application dev server and build tool

Latest version **0.3.10** (published 2017-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install unv
pnpm add unv
yarn add unv
bun add unv
```

Provides the command `unv`.

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.10 |
| Published | 2017-09-08 |
| First published | 2016-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 30 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | ashaffer88, joshrtay, weo-edu |

## Links

- npm: https://www.npmjs.com/package/unv
- Repository: https://github.com/weo-edu/unv
- Homepage: https://github.com/weo-edu/unv#readme
- Issues: https://github.com/weo-edu/unv/issues
- npm.io page: https://npm.io/package/unv

## Dependencies (30)

- [mz](https://npm.io/package/mz.md) ^2.3.1
- [koa](https://npm.io/package/koa.md) ^1.1.2
- [envify](https://npm.io/package/envify.md) ^3.4.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.5.2
- [envitro](https://npm.io/package/envitro.md) ^1.0.3
- [babelify](https://npm.io/package/babelify.md) ^7.2.0
- [farmhash](https://npm.io/package/farmhash.md) ^1.1.1
- [watchify](https://npm.io/package/watchify.md) github:ashaffer/watchify
- [@f/switch](https://npm.io/package/@f/switch.md) ^1.0.1
- [koa-error](https://npm.io/package/koa-error.md) ^1.1.3
- [koa-mount](https://npm.io/package/koa-mount.md) ^1.3.0
- [opt-stack](https://npm.io/package/opt-stack.md) ^1.0.7
- [uglifyify](https://npm.io/package/uglifyify.md) ^3.0.1
- [browserify](https://npm.io/package/browserify.md) ^13.0.0
- [koa-static](https://npm.io/package/koa-static.md) ^2.0.0
- [@f/debounce](https://npm.io/package/@f/debounce.md) ^1.0.0
- [br-cloud-fs](https://npm.io/package/br-cloud-fs.md) ^0.1.1
- [koa-compose](https://npm.io/package/koa-compose.md) ^2.4.0
- [koa-compress](https://npm.io/package/koa-compress.md) ^1.0.9
- [babel-register](https://npm.io/package/babel-register.md) ^6.4.3
- [browserify-hmr](https://npm.io/package/browserify-hmr.md) github:ashaffer/browserify-hmr
- [bundle-collapser](https://npm.io/package/bundle-collapser.md) ^1.2.1
- [@f/promise-stream](https://npm.io/package/@f/promise-stream.md) ^1.1.3
- [@joshrtay/decache](https://npm.io/package/@joshrtay/decache.md) ^4.0.1
- [@f/thunk-to-promise](https://npm.io/package/@f/thunk-to-promise.md) ^1.1.1
- [babel-preset-stage-2](https://npm.io/package/babel-preset-stage-2.md) ^6.5.0
- [cached-path-relative](https://npm.io/package/cached-path-relative.md) ^1.0.0
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) ^6.6.5
- [babel-preset-es2015-without-regenerator](https://npm.io/package/babel-preset-es2015-without-regenerator.md) ^1.0.1

## Recent versions

- 0.3.10 (latest) — 2017-09-08
- 0.3.9 — 2016-12-10
- 0.3.8 — 2016-09-22
- 0.3.7 — 2016-09-22
- 0.3.6 — 2016-09-22
- 0.3.5 — 2016-09-12
- 0.3.4 — 2016-09-09
- 0.3.3 — 2016-08-08
- 0.3.2 — 2016-07-29
- 0.3.1 — 2016-07-25
- 0.3.0 — 2016-07-22
- 0.2.33 — 2016-06-08
- 0.2.32 — 2016-06-08
- 0.2.31 — 2016-06-08
- 0.2.30 — 2016-06-08
- … 38 more at https://npm.io/package/unv/versions

## README

# unv

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

Universal, javascript-only application dev server and build tool.

## Installation

    $ npm install unv

## Overview

unv is *not* trying to be everything for everyone. It's designed to work very well with the way we bootstrap projects at Weo. If your projects are like ours, it'll be great. If not, look into something like [budo](https://github.com/mattdesl/budo) which is less opinionated.

## CLI

If you have a `src/client.js` or a `lib/client.js` (in that order), then you can just run:

`unv dev`

In your project's root. If you want more options, then...

### Options

  * `--port <port>`   - Port to listen on. Defaults to `3000`.
  * `--server <file>` - Server entrypoint
  * `--client <file>` - Client entrypoint
  * `--modules <dir>` - Root module folder. E.g. `src/`. This folder will be added to the module resolution path, so that you can require from it directly. E.g. `require('components/modal')`, assuming your src folder contains a 'components' folder. This is of course *in addition* to node_modules. All of your transforms / babel plugins will run on these modules without issue (often there are problems with this if you try to use symlinks from node_modules).

## client.js

Doesn't need to export anything - just your clientside entrypoint and the first thing that will run in the browser. Example:

```javascript
import domready from '@f/domready'
import vdux from 'vdux/dom'

domready(() => vdux({
  app,
  middleware,
  reducer
}))
```

## server.js

Your server.js file should export a single function of the form `render(request, urls)`. `urls.js` is the path to your javascript bundle, and `request` is a node request object. Your render function may return any yieldable value (e.g. promise, string, thunk, generator, etc.) that resolves to the HTML of the page you want to render.

Example:

```javascript
export default function *(req, urls) {
  const {state, html} = yield main(req)

  return `
    <html>
      <head>
        <script type='text/javascript'>
          window.__initialState__ = ${JSON.stringify(state)}
        </script>
        <script type='text/javascript' src='${urls.js}'></script>
      </head>
      <body>
        ${html}
      </body>
     </html>
     `
}
```

## Hot reloading

Hot reloading is turned on by default in the dev server, and since everything is javascript, it's the only type of reloading you'll need (i.e. no livereload). To support server-side hot reloading, your `server.js` may export a `replace` method.

Here's an example `replace` function:

```javascript
function replace () {
  invalidate(new RegExp('^' + path.resolve('./src')))
  main = require('./main').default
}

function invalidate (re) {
  forEach(remove, require.cache)

  function remove (val, key) {
    if (re.test(key)) {
      delete require.cache[key]
    }
  }
}
```

Client-side hot reloading works using the [browserify-hmr](https://github.com/AgentME/browserify-hmr) plugin.

## Assets (e.g. images)

In both your server-side and client-side code, you can just require/import any assets you may have and it will resolve to the url it's going to be served from. E.g.

```javascript
import weo from './weo.png'
import element from 'vdux/element'

function render () {
  return <img src={weo} />
}

export default render
```

## CSS

There is currently not a particular solution for css. Which means you're mostly limited to css-in-js solutions at the moment. At Weo, we use [jss-simple](https://github.com/ashaffer/jss-simple).

## Building for production

unv will also support building all of your assets and an asset map (similar to webpack's) for production, but that is still TBD.

## ES6

All of your code (server and client) will be babel'd from the start. So no need for any `server.babel.js` or anything like that.

## License

MIT

[travis-image]: https://img.shields.io/travis/weo-edu/unv.svg?style=flat-square
[travis-url]: https://travis-ci.org/weo-edu/unv
[git-image]: https://img.shields.io/github/tag/weo-edu/unv.svg?style=flat-square
[git-url]: https://github.com/weo-edu/unv
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/unv.svg?style=flat-square
[npm-url]: https://npmjs.org/package/unv

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