# hapi-universal-webpack-plugin

> Hapi plugin that implements dev, hot and hot-server middleware for weback

Latest version **0.2.0** (published 2019-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-universal-webpack-plugin
pnpm add hapi-universal-webpack-plugin
yarn add hapi-universal-webpack-plugin
bun add hapi-universal-webpack-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2019-03-15 |
| First published | 2018-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Rico Herwig |
| Maintainers | rherwig4711 |
| Keywords | webpack, dev-middleware, hot-middleware, hot-server-middleware, hapi, universal, server-side, rendering |

## Links

- npm: https://www.npmjs.com/package/hapi-universal-webpack-plugin
- Repository: https://github.com/rherwig/hapi-universal-webpack-plugin
- Homepage: https://github.com/rherwig/hapi-universal-webpack-plugin#readme
- Issues: https://github.com/rherwig/hapi-universal-webpack-plugin/issues
- npm.io page: https://npm.io/package/hapi-universal-webpack-plugin

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.1.0
- [webpack-dev-middleware](https://npm.io/package/webpack-dev-middleware.md) ^3.4.0
- [webpack-hot-middleware](https://npm.io/package/webpack-hot-middleware.md) ^2.24.3
- [webpack-hot-server-middleware](https://npm.io/package/webpack-hot-server-middleware.md) ^0.5.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2019-03-15
- 0.1.0 — 2018-12-13

## README

# Hapi Universal Webpack Plugin
This plugin integrates [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware), 
[webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) and 
[webpack-hot-server-middleware](https://github.com/60frames/webpack-hot-server-middleware)
into [hapi](https://hapijs.com) in order to provide hot-reloading of universal apps (i.e. apps
that run on the client and the server).

## Prerequisites
The following two packages are a peer dependency for this plugin.
 * Hapi (tested on >= 17.0)
 * webpack (tested on >= 4.0)

## Installation
```bash
$ npm i -D hapi-universal-webpack-plugin
```

## Usage
The following steps are required for you to implement the plugin and make
it work.

### Hapi
Before you start the server, you want to register the plugin. Provided you
have webpack configurations for client and server, the following snippet
will get you up and running.

```js
const HapiUniversalWebpackPlugin = require('hapi-universal-webpack-plugin');
const clientConfig = require('path/to/webpack/config');
const serverConfig = require('path/to/webpack/config');

server.register({
    plugin: HapiUniversalWebpackPlugin,
    options: {
        clientConfig,
        serverConfig,
    },
});
```

#### Options
The `options` object from the example above accepts the following values:

| Key                        | Type   | Default   | Required | Description                                                                                                                                                                  |
|----------------------------|--------|-----------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| clientConfig               | Object | undefined | yes      | webpack configuration for processing the client-side code.                                                                                                                   |
| serverConfig               | Object | undefined | no       | webpack configuration for processing the server-side code. Without this, the plugin will run in client-only mode, which is fine if you do not need server-side rendering.    |
| devMiddlewareOptions       | Object | {}        | no       | Options that get passed down to [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware). See their documentation for further information.                |
| hotMiddlewareOptions       | Object | {}        | no       | Options that get passed down to [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware). See their documentation for further information.        |
| hotServerMiddlewareOptions | Object | {}        | no       | Options that get passed down to [webpack-hot-server-middleware](https://github.com/60frames/webpack-hot-server-middleware). See their documentation for further information. |

### Webpack
A more detailed documentation on how to setup your webpack
configurations is coming very soon.
In the meantime, just refer to the `examples/` directory of this
repository, to see the plugin in action using the example of a universally
rendered VueJS application.

## Acknowledgement
[hapi-webpack-plugin](https://github.com/SimonDegraeve/hapi-webpack-plugin)
is a great solution if you do not need the server-side rendering part this
plugin provides. It also served as great inspiration for this implementation.

[webpack-hot-server-middleware](https://github.com/60frames/webpack-hot-server-middleware)
is the package that provides us with webpack-integration for server-side 
bundling.

## License
MIT

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