A
A
Artem Shchurin2017-04-27 10:39:58
JavaScript
Artem Shchurin, 2017-04-27 10:39:58

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>

Project structure:
fa30cf7baff54c6ab9d1d017a53004c0.png
Config:
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

1 answer(s)
O
Oleg Drapeza, 2017-04-27
@schurin

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 question

Ask a Question

731 491 924 answers to any question