'webpack only watching entry file

I have a projects where I would like webpack and the devserver to hot-reload my changes and refresh my browser as soon as I save a file in my project.

However, this all works great for my entry file (main.ts). But for the rest of my code that's located in the folder and sub-folders of ./game and ./ui, Webpack fails to detect the file changes (I don't think it even bothers watching).

Am I missing something?

Here is my webpack.config.js. FYI, the project uses TypeScript and dev-containers.

const path = require('path');
const copyPlugin = require("copy-webpack-plugin");

module.exports = {
  entry: './main.ts',
  mode:process.env.BUILD_ENV,
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, '../dist'),
  },
  plugins: [
    new copyPlugin({
      patterns: [
        { from: 'index.html', to: '../dist' }
      ],
    }),
  ],
  devServer: {
    static: {
      directory: path.join(__dirname, '../dist'),
    },
    compress: true,
    port: 9000,
    hot: true
  },
};

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source