Error serving chunks from basic code splitting
- Operating System: Windows 10
- Node Version: 8.6.0
- NPM Version: 5.3.0
- webpack Version: 3.10.0
- webpack-dev-server Version: 2.10.1
- [x] This is a bug
- [ ] This is a modification request
I'm new to code splitting and have been following the docs for react-loadable. Setup seemed straightforward, but now when I try and hit a url that should serve up a new chunk, I get an error saying the chunk cannot be found. When I build from webpack, the chunk is made just fine.
Code
webpack.config.js
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = () => {
return {
entry: './src/app.jsx',
output: {
path: path.resolve(__dirname, 'public', 'dist'),
filename: 'bundle.js',
chunkFilename: '[name].bundle.js',
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
}
]
},
resolve: {
extensions: [
'.js',
'.jsx'
]
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'public'),
historyApiFallback: true,
port: 8000,
publicPath: '/dist/',
lazy: false
},
plugins: [
new ExtractTextPlugin('style.css')
]
};
}
The script tag I put in index.html for my main bundle.js has src="./dist/bundle.js". However, when a new script tag gets created for the new chunk, the path is different. For that it is src="0.bundle.js". Could this discrepancy in paths be the cause? If so, is this an easy fix?
Expected Behavior
No error in serving generated js chunks
Actual Behavior
Error when serving js chunks
For Bugs; How can we reproduce the behavior?
Any help would be greatly appreciated!
Just figured this out. 100% me overlooking something. I simply needed my output to include publicPath: 'dist/'
@strausd Why don't you close this then.
Totally forgot, my bad!