webpack-dev-server can be set up to send you back to index.html and find your scripts for a single route like http://localhost:4301/sdr but when you put in a deeper route (or a single route with a / at the end) http://localhost:4301/sdr/dog it gets confused.
devServer: {
contentBase: './dist',
historyApiFallback: true
},
with http://localhost:4301/sdr/dog the server responds
x GET http://localhost:4301/sdr/bundle.js
adding /sdr to the the path in its search for bundle.js
How can I fix this. ... then I will try it on NGINX then with react-router then with navigo then with react-router-redux....
I also had this issue. I found the solution was to add publicPath: '/'
to my webpack config under output.
const base = {
entry: [
PATHS.app,
],
output: {
path: PATHS.build,
publicPath: '/',
filename: 'index_bundle.js',
},
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
{test: /\.css$/, loader: 'style!css?sourceMap&modules&localIdentName=[name]__[local]___[hash:base64:5]'},
{test: /\.json$/, loader: 'json'},
],
},
resolve: {
root: path.resolve('./app'),
},
}
const developmentConfig = {
devtool: 'cheap-module-inline-source-map',
devServer: {
contentBase: PATHS.build,
hot: true,
inline: true,
progress: true,
proxy: {
'/api': 'http://127.0.0.1:5000',
},
historyApiFallback: true,
},
plugins: [HTMLWebpackPluginConfig, new webpack.HotModuleReplacementPlugin()],
}
export default Object.assign({}, base, developmentConfig)
Here is more detailed documentation of this property: http://webpack.github.io/docs/configuration.html#output-publicpath
Here is the forum where there is a more detailed discussion of this issue: https://github.com/webpack/webpack/issues/443
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With