Search code examples
gruntjswebpack-dev-serverhtml5-history

webpack 2 historyApiFallback is not working, 404 not found


I just use simple grunt-webpack and it is not working. Always get 404. I need to use the Angular 2 router I can see webpack-dev-server is not working, not serving.

In the config I tried:

 output: {
        path: root(folder.build.dist.root),
        publicPath: '/',
        filename: '[name].js',
        chunkFilename: '[id].chunk.js'
    },
    devServer: {
        historyApiFallback: {
            index: '/index.html'
        },
        stats: true,
        inline: true,
        progress: true
    }

Solution

  • Yes, a fixed it! I was using grunt-webpack, so the config devServer not working. I had to add the devServer config with grunt like this:

    "webpack-dev-server": {
            options: {
                webpack: webpackConfigDev,
            },
            'cory-run': webpackConfigDev.devServer
        },