Webpack-dev-server serves a directory list instead of the app page Webpack-dev-server serves a directory list instead of the app page reactjs reactjs

Webpack-dev-server serves a directory list instead of the app page


If you're using webpack's dev server you can pass in options to use /public as a base directory.

devServer: {    publicPath: "/",    contentBase: "./public",    hot: true},

See the webpack configuration docs, and specifically the webpack dev server docs for more options and general information.


You can also add the --content-base flag to your start-up script, e.g.

    "scripts": {        "start:dev": "webpack-dev-server --inline --content-base ./public"    }


In my case, I misspelled 'index.html' when I set up the HTMLWebpackPlugin. Double check your filenames if you're using this plugin.

var HTMLWebpackPlugin = require('html-webpack-plugin');var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({  template: __dirname + '/app/index.html',  filename: 'index.html',  inject: 'body'});