Vojtech Vojtech - 1 year ago 113
AngularJS Question

Angular2 with webpack reports error 404 index.html not found

Using Angular2 I started a project but when I open http://localhost:8080/webpack-dev-server/index.html or http://localhost:8080/index.html it reports 404 index.html not found. I have no idea why. I'm using Windows. The project is available on Github.

Answer Source

Since your project has split your webpack configuration, it needs to merge those configurations to webpack understand all your parameters.

The simplest way is using _.merge method from lodash, see more at: https://lodash.com/docs/4.16.4#merge

First you install the lodash dependency:

npm install --save-dev lodash

Then you merge your configurations, your webpack.config.js should look like:

var path = require('path');
var webpack = require('webpack');
var helpers = require('./helpers');
var _ = require('lodash');

var commonConfig = require('./webpack.common.js');

module.exports = _.merge(commonConfig, {
    devtool: 'cheap-module-eval-source-map', // source-map
    output: {
        path: helpers.root('dist'),
        //publicPath: '/',
        filename: '[name].js',
        chunkFilename: '[id].chunk.js',
    devServer: {
        historyApiFallback: true,
        stats: 'minimal'

Hope this can help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download