9.5.0 • Published 6 years ago

hops-plugin v9.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Hops Plugin

deprecated

This package is deprecated. Please use hops and hops-build instead.

Hops assumes you will write an Express-style middleware, transpiles it and makes it easy to use in non-transpiled and even non-server code. Hops' plugin is a simple helper to simplify using your custom middleware in a Webpack build.

You can override hops' default Webpack configuration by passing a config object to the Plugin constructor. Supported config options equal those supported in package.json.

Target Audience

If you want to use your Webpack build to generate static pages using your own custom Express middleware, written in ECMAScript and transpiled using Webpack, this plugin might be what you're looking for. Phew.

Example

This example shows how to write and configure a custom middleware and use it in a webpack plugin that will generate two html files (foo/index.html and bar/index.html) in the webpack output folder.

package.json
{
  ...
  "server": "src/server.js"
  ...
}
src/server.js
export default (req, res) => {
  switch (req.url) {
    case '/foo':
      res.write('hello foo');
      break;
    case '/bar':
      res.write('hello bar');
      break;
    default:
      res.writeHead(404);
      res.write('not found');
      break;
  }
  res.end();
};
webpack.config.js
const HopsPlugin = require('hops-plugin');
const webpackConfig = require('hops-build-config').nodeConfig;

const locations = ['foo', 'bar'];

module.exports = {
  ...
  plugins: [
    new HopsPlugin(locations, webpackConfig /*, watchOptions */)
  ]
  ...
}
9.5.0

6 years ago

9.4.2

6 years ago

9.4.1

6 years ago

9.4.0

6 years ago

9.3.0

6 years ago

9.1.1

6 years ago

9.0.1

6 years ago

8.0.0

6 years ago

7.2.0

7 years ago

7.1.0

7 years ago

7.0.0

7 years ago

7.0.0-0

7 years ago

6.2.8

7 years ago

6.2.7

7 years ago

6.2.6

7 years ago

6.2.5

7 years ago

6.2.4

7 years ago

6.2.3

7 years ago

6.2.2

7 years ago

6.2.0

7 years ago

6.1.2

7 years ago

6.1.1

7 years ago

6.1.0

7 years ago

6.0.0

7 years ago

6.0.0-beta.24

7 years ago

6.0.0-beta.23

7 years ago

6.0.0-beta.22

7 years ago

6.0.0-beta.21

7 years ago

6.0.0-beta.g20

7 years ago

6.0.0-beta.19

7 years ago

6.0.0-beta.18

7 years ago

6.0.0-beta.17

7 years ago

6.0.0-beta.16

7 years ago

6.0.0-beta.15

7 years ago

6.0.0-beta.14

7 years ago

6.0.0-beta.13

7 years ago

6.0.0-beta.12

7 years ago

6.0.0-beta.11

7 years ago

6.0.0-beta.10

7 years ago

6.0.0-beta.9

7 years ago

6.0.0-beta.8

7 years ago

6.0.0-beta.7

7 years ago

6.0.0-beta.6

7 years ago

6.0.0-beta.5

7 years ago

6.0.0-beta.4

7 years ago

6.0.0-beta.3

7 years ago

6.0.0-beta.2

7 years ago

6.0.0-beta.1

7 years ago

0.1.0

7 years ago