npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hapi-webpack-dev-plugin

v1.2.0

Published

a plugin to integrate the web-pack-dev-server as a hapi plugin into a hapi server instead of using express

Downloads

10

Readme

hapi-webpack-dev-server-plugin

This is a plugin for hapijs providing the necessary routes to function as a webpack-dev-server for the awesome webpack project directly in hapijs. The actual Webpack-dev-server is implemented with express.js and since we are heavily using the fabulous hapijs as our main backend framework we found it very useful to have everything right there. This avoids tweaking SOP related things just for dev purposes.

Just like the original webpack-dev-server we also want to give out a quick warning:

DON'T USE THIS PLUGIN IN PRODUCTION!

>= v1.1.2 -> Requirements: hapijs ^14.x.x

< v1.1.2 -> Requirements: hapijs ^8.x.x

State: In Progress (meaning not hot code replacement at the moment, but auto relaoding works just fine)

Basic Usage

we tend to structure our apps like

- server_plugin
    index.js
- webpack_frontend
    - src
        main.js
    webpack.config.js
server.js

with that structure in mind you'd setup the dev-server-plugin in the server.js as follows

var Webpack = require('webpack');
var Hapi = require('hapi');

//basic webpack config, see webpack api docs for all options
var webpackConf = require('./webpack_frontend/webpack.config.js');
webpackConf.entry = {
    app: './webpack_frontend/src/main.js' //this is needed to have the correct relative paths for the webpack compiler which now runs from the base dir rather than from webpack_frontend
};
webpackConf.devtool = 'source-map';

//create the webpack compiler
compiler = Webpack(webPackConfig);

//create hapi server
server = new Hapi.Server();
server.connection({
	port: port,
	host: address
});

//start server and register dev server as plugin
server.start(function () {
  server.register({
    register: require('hapi-webpack-dev-plugin'),
    options: {
      compiler: compiler,
      //no loginfo
      quiet: true,
      //where is the index.html located
      devIndex: ".", //not needed if devView is configured
      devView: { //allows to configure a view with whatever engine hapi has been configured to induce e.e. session information on startup
            name: 'main.html',
            data: function (request) {
                var tplData = {
                    "entrypoint": "dist/app.js"
                };
                return tplData;
            }
        }
      /*
      ,watchDelay: 200
      ,noInfo: false
      ,headers: {
      x-dynamic-content: true
      }
      */
    }
    }, function (err) {
      console.log(err);
  });
});

Config Options

{
	name: "the name of the view" // mandatory, elsewise the devIndex will be used
	data: "tplData" // an object, a function which gets passed in the request, or empty - data is supposed to determine tplData for the view
}

Questions?

Feel free to ask questions if anything is badly described!

[email protected] or an Issue!