Registry / web-framework / hapi-webpack-plugin

hapi-webpack-plugin

JSON →
library3.0.0jsnpmunverified

Webpack middleware plugin for Hapi.js that integrates webpack-dev-middleware and webpack-hot-middleware to enable Hot Module Replacement (HMR) during development. Version 3.0.0 supports Hapi >= 17.x and webpack >= 2.x. It offers two usage modes: passing an object with compiler/assets/hot options, or a path to a webpack config file. Compared to alternatives like hapi-webpack-dev-middleware, this plugin bundles both middlewares and supports HMR out of the box. Release cadence is sporadic; last release was in 2018, and it is considered stable but unmaintained.

npm install hapi-webpack-plugin
INSTALL
IMPORT
SIG · HAPI-WEBPACK-PLUGI
H
hapi-webpack-plugin
web-frameworkjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebpackPlugin
import WebpackPlugin from 'hapi-webpack-plugin'
const WebpackPlugin = require('hapi-webpack-plugin')
ESM default export; CJS require works but is not recommended for newer versions.
Server (hapi)
import {Server} from '@hapi/hapi' or 'hapi'
const Server = require('hapi').Server
Hapi v17+ uses @hapi/hapi; older hapi package is deprecated.
Webpack
import Webpack from 'webpack'
const webpack = require('webpack')
ESM import works; webpack also has named exports but this plugin uses default.

Registers the hapi-webpack-plugin with Hapi v17+, passing a webpack compiler and enabling HMR.

import {Server} from '@hapi/hapi'; import Webpack from 'webpack'; import WebpackPlugin from 'hapi-webpack-plugin'; const server = new Server({port: 3000}); const compiler = Webpack({ entry: './src/index.js', output: {path: __dirname + '/dist', filename: 'bundle.js'}, mode: 'development' }); async function start() { await server.register({ plugin: WebpackPlugin, options: { compiler, assets: {publicPath: '/'}, hot: true } }); await server.start(); console.log('Server running at:', server.info.uri); } start().catch(console.error);
Debug
Known issues
breakingVersion 3.0.0 only works with Hapi >= 17.x; does not support Hapi 16.x or older.
fix
Use version 2.x.x for Hapi <= 16.x.
affects: >=3.0.0
deprecatedThe 'hapi' package is deprecated; use '@hapi/hapi' for Hapi v17+.
fix
Install @hapi/hapi instead of hapi.
affects: >=17
gotchaThe plugin expects 'compiler' property in options; misspelling or missing will cause silent failure.
fix
Ensure options object includes 'compiler', 'assets', and 'hot' correctly.
affects: >=1.0.0
gotchaWhen using path option, the webpack config file must export a valid configuration object, not a function.
fix
Export an object from webpack.config.js.
affects: >=3.0.0
deprecatedHapi v16 callback style registration is deprecated; use async/await with Hapi v17.
fix
Upgrade to Hapi v17+ and use async registration.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'webpack-dev-middleware'
Missing webpack-dev-middleware dependency.
fix
npm install webpack-dev-middleware --save-dev
TypeError: compiler is not a function
Webpack compiler not initialized correctly.
fix
Call Webpack(config) to create compiler, then pass it.
AssertionError: options.compiler must be a webpack compiler instance
Options missing 'compiler' property or it's not a valid compiler.
fix
Pass {compiler, assets, hot} in options.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
webpack-dev-middlewarerequiredCore middleware for serving webpack assets
webpack-hot-middlewareoptionalMiddleware for Hot Module Replacement
Agent activity
6 hits · last 30 days
node
6
Resources
hapi-webpack-plugin — npm install hapi-webpack-plugin · libregistry