Skip to content

Setting contentBase to false with historyApiFallback on throws an error #791

@coltonw

Description

@coltonw

Do you want to request a feature or report a bug?

Bug
What is the current behavior?
webpack-dev-server fails on startup with the options mentioned in the title:
contentBase set to false with historyApiFallback on

The exact error is:

TypeError: root path required
    at Function.serveStatic [as static] (.../node_modules/serve-static/index.js:40:11)
    at Object.contentBaseFiles (.../node_modules/webpack-dev-server/lib/Server.js:269:32)
    at Server.<anonymous> (.../node_modules/webpack-dev-server/lib/Server.js:331:20)
    at Array.forEach (native)
    at new Server (.../node_modules/webpack-dev-server/lib/Server.js:330:40)
    at startDevServer (.../node_modules/webpack-dev-server/bin/webpack-dev-server.js:379:12)
    at processOptions (.../node_modules/webpack-dev-server/bin/webpack-dev-server.js:317:3)
    at Object.<anonymous> (.../node_modules/webpack-dev-server/bin/webpack-dev-server.js:441:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

If the current behavior is a bug, please provide the steps to reproduce.

{
  entry: './src/js/index.jsx',
  output: {
    path: path.resolve('./dist'),
    filename: 'index.js',
    publicPath: '/app/',
  },
  resolve: {
    extensions: ['.js', '.jsx'],
  },
  plugins: [
    new CopyPlugin([{ from: './public' }]),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(env),
      API_URL: JSON.stringify(backendUrl),
    }),
  ],
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js/,
        exclude: /node_modules/,
        loader: 'babel-loader',
      },
    ],
  },
  devServer: {
    compress: true,
    contentBase: false,
    publicPath: '/app/',
    quiet: true,
    https: true,
    historyApiFallback: {
      index: '/app/',
    },
    proxy: {
      ...
    },
  }
}

What is the expected behavior?
This should just work. It looks in the code like you are assuming that historyApiFallback must point to a file but it works great (and it my opinion makes more sense) to have it point to a server path, in this case, the same path as my base public path.

Please mention your webpack and Operating System version.
webpack 2.2.1
OS X El Capitan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions