webpack-dev-server.watchContentBase 不查看内容库中的所有文件

webpack-dev-server.watchContentBase doesn't watch all files inside content base

如果有人能向我解释为什么 webpack-dev-server 不会在 home.html 代码更改时重新加载浏览器页面,但会触发重新加载,我将不胜感激home.js 或 index.html 代码更改。

项目结构简化版-

/app
  -app.js
  -index.html
  /core
    -home.html
    -home.js (imported in app.js)
  /dist
    -app.bundle.js

webpack.config.js

const path = require('path');

module.exports = {
    entry: './app/app.js',
    output: {
        path: path.resolve(__dirname, './app/dist'),
        filename: 'app.bundle.js'
    },
    devServer: {
        contentBase: path.resolve(__dirname, './app'),
        publicPath: '/dist/',
        watchContentBase: true
    }
}

我正在使用 webpack@3.7.1 和 webpack-dev-server@2.11.1

您非常接近,只需将包含 .html 个文件的每个文件夹添加到 contentBase

devServer: {
  contentBase: [
    path.join(__dirname, 'app'),
    path.join(__dirname, 'app/core'),
    // and so on...
  ],
}