It's a bit unusual that contentBase isn't working. Does watching work otherwise, for example when you change the entry script? On some systems you may need to poll or increase the number of inotify watchers.
– Filip DupanovićDec 29 '18 at 14:23

1 Answer
1

I'm not sure if there's anything readily available that's better than contentBase. webpack, webpack-dev-server and webpack-dev-middleware all expose an invalidate(callback) helper, but it would require you to create your custom script to programmatically manage the compiler, server or middleware to invoke the handler.

Something similar to this that should work across all compilers configured for watching is to add additional files as compilation dependencies and let webpack handle the invalidation. You can also do this when using webpack programmatically, but it's also really easy to write your own plugin and perform this from the configuration. Here's an example:

It uses the beforeCompile hook to add a robots.txt file as a compilation dependency. In development where we don't perform any caching, this should cause the development server to reload the page because new chunks were emitted.

There's probably also other options. One thing that comes to mind is maybe having a development entry or some other module that uses require.context, but I think these options would involve more effort.