# nunjucks-browsersync-server

> Easily create and configure a browser-sync + nunjucks server for serving static pages on the fly during template development

Latest version **2.0.0** (published 2017-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install nunjucks-browsersync-server
pnpm add nunjucks-browsersync-server
yarn add nunjucks-browsersync-server
bun add nunjucks-browsersync-server
```

## 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 | 2.0.0 |
| Published | 2017-06-15 |
| First published | 2016-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Simon Buerger |
| Maintainers | simonbuerger |
| Keywords | browser-sync, nunjucks, express, templates, server |

## Links

- npm: https://www.npmjs.com/package/nunjucks-browsersync-server
- Repository: https://github.com/bluegrassdigital/nunjucks-browsersync-server
- Homepage: https://github.com/bluegrassdigital/nunjucks-browsersync-server#readme
- Issues: https://github.com/bluegrassdigital/nunjucks-browsersync-server/issues
- npm.io page: https://npm.io/package/nunjucks-browsersync-server

## Dependencies (9)

- [glob](https://npm.io/package/glob.md) ^7.1.1
- [path](https://npm.io/package/path.md) ^0.12.7
- [yargs](https://npm.io/package/yargs.md) ^6.3.0
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [express](https://npm.io/package/express.md) ^4.14.0
- [on-headers](https://npm.io/package/on-headers.md) ^1.0.1
- [portfinder](https://npm.io/package/portfinder.md) ^1.0.9
- [compression](https://npm.io/package/compression.md) ^1.6.2
- [browser-sync](https://npm.io/package/browser-sync.md) ^2.17.5

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-06-15
- 1.0.0 — 2016-11-06

## README

# nunjucks-browsersync-server

Easily create and configure a browser-sync + nunjucks server for serving static pages on the fly during template development

## Installation

`npm install nunjucks-browsersync-server`

## API

<a name="module_server"></a>

## server
Server module

<a name="module_server.start"></a>

### server.start(config)
Start a nunjucks-browsersync-server instance

**Kind**: static method of <code>[server](#module_server)</code>  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| config | <code>Object</code> |  |  |
| [config.staticPath] | <code>String</code> |  | A path containing static assets you want to serve along with your nunjucks pages |
| [config.basePort] | <code>Number</code> | <code>8020</code> | The port you want the server to start looking for available ports to serve on. The browser-sync ui server will start on the next port after the one that the server starts on |
| config.nunjucks | <code>Object</code> |  | An object of nunjucks configuration options |
| config.nunjucks.root | <code>string</code> |  | The root path where your nunjucks files are |
| config.nunjucks.renderPath | <code>string</code> |  | The folder name of the pages folder you want to render on the server. Is also used to match the urls under which you want nunjucks to render |
| [config.nunjucks.data] | <code>function</code> |  | A function returning the data you want to pass to the nunjucks templates |
| [config.nunjucks.globals] | <code>Object</code> |  | Any other nunjucks globals you want to add |
| [config.nunjucks.extension] | <code>string</code> | <code>&quot;&#x27;.njk&#x27;&quot;</code> | The extension to match for nunjucks files |
| [config.nunjucks.configureEnv] | <code>function</code> |  | A function that exposes the nunjucks environment instance in order to directly manipulate it if necessary |
| [config.browserSync] | <code>Object</code> |  | browser-sync configuration optiosn to mix with the defaults. See browser-sync docs. |

**Example**  
```js
// Imagine a directory structure// - assets// - html// -- pages// --- page-1.njk// -- layouts// -- partials// -- data.jsonvar server = require('nunjucks-browsersync-server')server.start({  staticPath: './assets',  browsersync: {    files: ['./assets/**', './html/**']  },  nunjucks: {    root: './html',    renderPath: 'pages',    globals: require('../nunjucks'),    data: require('./html/data.json')  }})// Now you can go to localhost:8020/pages/page-1.html and it will render the nunjucks page at './html/pages/page-1.njk' on the fly
```

## Contributing to nunjucks-browsersync-server

[Standard JS](http://standardjs.com/) applies

camelCase for function and variable names

[Github Flow](https://guides.github.com/introduction/flow/) - branch, submit pull requests

### Getting set up

- Pull the repo
- run `npm install`
- run `gulp` to build from `index.es6.js` to the compiled `index.js` file

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