Running a node express server using webpack-dev-server : <p>I'm using webpack to run my react frontend successfully using the following config:</p>

<pre><code>{
    name: 'client',
    entry: './scripts/main.js',
    output: {
        path: __dirname,
        filename: 'bundle.js'  
    },
    module: {
        loaders: [
            {
                test: /.jsx?$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
                query:{
                    presets: ['es2015', 'react', 'stage-2']
                }
            }
        ]
    }
}
</code></pre>

<p>I'm trying to put up a node.js express backend as well, and would like to run that through webpack as well, so that I have a single server running both the backend and frontend, and because I want to use babel to  transpile my javascript.</p>

<p>I made a quick testserver looking like this:</p>

<pre><code>var express = require('express');
console.log('test');

var app = express();

app.get('/', function(req, res){
    res.send("Hello world from Express!!");
});

app.listen(3000, function(){
    console.log('Example app listening on port 3000');
});
</code></pre>

<p>If I run this with <code>node index.js</code> and open my browser on <code>localhost:3000</code> it prints "Hello world from Express!!". So far so good. Then I tried creating a web-pack config for it:</p>

<pre><code>var fs = require('fs');
var nodeModules = {};
fs.readdirSync('node_modules')
    .filter(function(x) {
        return ['.bin'].indexOf(x) === -1;
    })
    .forEach(function(mod) {
        nodeModules[mod] = 'commonjs ' + mod;    
});

module.exports = [
{
    name: 'server',
    target: 'node',
    entry: './index.js',
    output: {
        path: __dirname,
        filename: 'bundle.js'
    },
    externals: nodeModules,
    module: {
        loaders: [
            { 
                test: /\.js$/,
                loaders: [
                    'babel-loader'
                ]
            },
            {
                test:  /\.json$/, 
                loader: 'json-loader'
            }
        ]
    }
}   
</code></pre>

<p>When I run the command <code>webpack-dev-server</code> it starts up successfully (it seems). However, if I go to my browser on <code>localhost:3000</code> now, it just says that the webpage is not available, just as when the server is not running at all.</p>

<p>I'm very new to both node and webpack, so either I have made a small mistake somewhere, or I'm way off ;)</p>
