Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
coltonw opened this issue Feb 17, 2017 · 2 comments
Closed

Comments

@coltonw
Copy link
Contributor

coltonw commented Feb 17, 2017

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

@SpaceK33z
Copy link
Member

SpaceK33z commented Feb 17, 2017

Thanks for your clear bug report.There are several tests for contentBase and historyApiFallback, but apparently none that tests this combination. Would you be willing to do a PR? I can maybe look at it this weekend, but not sure.

@coltonw
Copy link
Contributor Author

coltonw commented Feb 18, 2017

I am working on a PR

SpaceK33z pushed a commit that referenced this issue Feb 18, 2017
…#791 (#797)

* Setting contentBase to false with historyApiFallback on works properly #791

* Remove console.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants