Answer the question
In order to leave comments, you need to log in
Why doesn't webpack-dev-server provide a bundle for index.hmtl?
Good day
I decided to start a webpack dev server, the config starts up, I get index.html
But for the bundles connected on the page I get 404 The bundle is connected to the page
:
<script type="text/javascript" src="bundles/index.js"></script>
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
index: './entry_points/index.js'
},
output: {
filename: '[name].js',
path: path.join(__dirname, '/bundles/')
},
watchOptions: {
pull: true,
ignored: /node_modules/
},
devServer: {
contentBase: path.join(__dirname),
historyApiFallback: true,
port: 9002
}
};
Answer the question
In order to leave comments, you need to log in
Webpack-dev-server does not write bundled files to disk, but stores them in memory. contentBase only says where to get static files from.
You need just such an address - add
Better use HtmlWebpackPlugin , it will create index.html + add your index.js to the page.
At the moment your index.js is virtually in the same directory as index.html. output.publicPath: '/bundles/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question