'Cannot GET / - How to get webpack-dev-server to load my index.html

I'm having trouble loading up my index.html file when launching webpack-dev-server.

I am following Maximilian Schwarzmüller's course on Understanding TypeScript, and his versions of the tools seem to be working fine with the code he is writing.

const path = require('path');

module.exports = {
  mode: 'development',
  entry: './src/app.ts',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    publicPath: 'dist'
  },
  devtool: 'inline-source-map',
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.js']
  }
};

I've even used almost the exact directory structure that he seems to be using in this course.

File directory structure

Building works fine when I use lite-server to render the small app, but for some reason I can't set the paths correctly when it comes to webpack-dev-server.

I keep getting the Cannot GET / error.

Can anyone help?



Sources

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

Source: Stack Overflow

Solution Source