1
votes

I use the html-webpack-plugin, along with the html-webpack-template, which provides support for "injecting" things onto the window related to the html served up by the html-webpack-plugin in the webpack-dev-server.

In this case, I'm actually generating the 'uiContext' below, from a require of a sibling module. What I'd like to do is watch that module for changes, then upon changes, tell the webpack-dev-server to reload (with the changes to uiContext).

Thoughts?

var HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlWebpackTemplate = require('html-webpack-template');
var uiContext = require('./server/ui-context');
// ...
plugins: [
new HtmlWebpackPlugin({
  template: htmlWebpackTemplate,
  window: {
    uiContext
  }
}),
1

1 Answers

0
votes

There's an open ticket for this on webpack-dev-server, #440. Diskodan mentioned a hacky way to get it working, using nodemon:

"scripts": {
  "start": "nodemon --watch webpack.config.js ./node_modules/.bin/webpack-dev-server",
}