<!--
Please note that this template is not optional.
Please fill out _ALL_… fields, or your issue may be closed as "invalid."
Please do not delete this template.
Please ask questions on StackOverflow or Gitter (https://gitter.im/webpack/webpack).
General questions, how-to questions, and support requests will be closed.
-->
* Operating System: Windows 10
* Node Version: 8.11.1
* NPM Version: 5.6.0
* webpack Version: ^4.16.5
* webpack-dev-server Version:^3.1.5
<!--
Please place an x, no spaces, in all [ ] that apply
Please note that we are NOT accepting FEATURE requests at this time.
-->
- [x] This is a **bug**
- [ ] This is a **modification** request
I am trying to build a plugin for multiple entry points so that one does not have to mention any entry point to webpack.config.js file at all. My plugin loops through the files in "src/js/" folder and set found (i.e. index.js, about.js) javascript files as entry points and then it checks for html files of same name (i.e. index.html, about.html) in "src/" folder if found it push that into html-webpack-plugin as template and generate compiled version of html file too in dist folder or if there is not such html file found then html-webpack-plugin will generate its own basic html file to dist folder.
**Now, the problem is, is working perfectly when I am running "npm run build", but when I am running "npm run start" and then if I modify any file then its not reloading the page in browser, I had to reload browser myself and then modification shows.**
**I have created a github repo with a minimal version of this . The plugin I have written is in "/multiple_entry_point_plugin/" folder.**
https://github.com/neo7official/multiple-entry-point-plugin
### Code
<!--
If you have a large amount of code to share which demonstrates the problem
you're experiencing, or your webpack config is very large, please provide a link
to your repository rather than pasting code. We'd also encourage you to use a
Github Gist link instead of pasting code. Otherwise, please paste relevant
short snippets below.
For bugs, please do consider providing a link to a stripped-down, bare-bones
repo that can reproduce the problem you're experiencing. Many times, bugs
aren't actual bugs, but rather specific issues with loaders, plugins, or
an environment/OS. Problems with complicated or large applications will almost
always require this to be triaged.
-->
```js
// webpack.config.js
const path = require("path");
const src_path = path.resolve('src/');
const dist_path = path.resolve('dist/');
const multipleEntryPoints = require("./multiple_entry_point_plugin/multipleEntryPoints");
const webpackDevServer = require("webpack-dev-server");
module.exports = {
mode:"development",
output:{
filename:"js/[name].js",
path:dist_path,
publicPath:"/",
},
plugins:[
new multipleEntryPoints()
],
devServer:{
port:3000,
overlay: true,
historyApiFallback: true,
open:true,
hot:false,
watchOptions: {
poll: true
}
}
}
```
```js
// This is my plugin code.
const fs = require("fs");
const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin");
const weblog = require('webpack-log');
const log = weblog({ name: 'MEP' });
const chalk = require("chalk");
class multipleEntryPoints{
constructor(options){
this.options = Object.assign({
srcFolder:"./src",
distFolder:"./dist",
commonsChunk:true,
}, options);
this.build_html = this.build_html.bind(this);
this.create_bundle = this.create_bundle.bind(this);
}
create_bundle(item, name, compiler){
log.info(chalk.bgGreen.black(`Entry point mounted - ${item}`));
compiler.options.entry[name] = item;
}
build_html(html_path, name, compiler){
if(fs.existsSync(html_path)){
new htmlWebpackPlugin(
{
filename:`${name}.html`,
template:html_path,
chunks:[`${name}`]
}
).apply(compiler);
}else{
new htmlWebpackPlugin({filename:`${name}.html`, chunks:[`${name}`]}).apply(compiler);
}
}
normalize(name){
return name.split(".")[0].replace("_", "-");
}
apply(compiler){
compiler.options.entry = {};
compiler.hooks.entryOption.tap("multipleEntryPoints", (compilation, entries) => {
var item, name;
log.info(chalk.bgYellow.black("**** MultipeEntryPoints Starts ****"));
fs.readdirSync(path.resolve(this.options.srcFolder, "js/")).forEach(file =>{
if(file.split(".").length > 1){ //ignoring folder names
item = path.resolve(this.options.srcFolder, `js/${file}`);
name = this.normalize(file);
this.create_bundle(item, name, compiler);
var html_path = path.resolve(this.options.srcFolder,`${name}.html`);
this.build_html(html_path, name, compiler);
};
});
log.info(chalk.bgYellow.black("***** MultipeEntryPoints Ends *****"));
});
}
}
module.exports = multipleEntryPoints;
```
### Expected Behavior
Browser should reload if any of html, css, js file get modified.
### Actual Behavior
Console shows its compiling but browser does not reloading the page on html/css/js file modification.
### For Bugs; How can we reproduce the behavior?
https://github.com/neo7official/multiple-entry-point-plugin
### For Features; What is the motivation and/or use-case for the feature?