Webpack with a client/server node setup?
<p>I'm trying to set up a webpack-based flow for an Angular2 app with a node backend server. After many hours banging my head against it, I've managed to get the client to build happily, but I can not figure out how to now integrate my server build. My server uses generators, so must target ES6, and it needs to point to a different typings file (main.d.ts instead of browser.d.ts).. </p>

<p>My source tree looks like;</p>

<pre><code>/
-- client/
-- -- &lt;all my angular2 bits&gt; (*.ts)
-- server/
-- -- &lt;all my node/express bits&gt; (*.ts)
-- webpack.config.js
-- typings/
-- -- browser.d.ts
-- -- main.d.ts
</code></pre>

<p>I thought perhaps just a tsconfig.json in the client and server folders would work, but no luck there. I also can't find a way to get html-webpack-plugin to ignore my server bundle and not inject it into index.html. My current tsconfig and webpack are below, but has anyone succeeded in getting webpack to bundle a setup like this? Any pointers would be much appreciated.</p>

<pre><code>{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "declaration": false,
        "removeComments": true,
        "noEmitHelpers": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    },
    "files": [
        "typings/browser.d.ts",
        "client/app.ts",
        "client/bootstrap.ts",
        "client/polyfills.ts"
    ]
}
</code></pre>

<p>and my webpack.config.js;</p>

<pre><code>var Webpack = require('webpack');
var HtmlWebpackPlugin  = require('html-webpack-plugin');
var Path = require('path');

module.exports = {
  entry: {
    'polyfills': Path.join(__dirname, 'client', 'polyfills.ts'),
    'client': Path.join(__dirname, 'client', 'bootstrap.ts')
  },
  output: {
    path:     Path.join(__dirname, 'dist'),
    filename: '[name].bundle.js'
  },
  resolve: {
    extensions: ['', '.js', '.json', '.ts']
  },
  module: {
    loaders: [
      {
        test: /\.ts$/,
        loader: 'ts-loader',
        query: {
          ignoreDiagnostics: [
            2403, // 2403 -&gt; Subsequent variable declarations
            2300, // 2300 -&gt; Duplicate identifier
            2374, // 2374 -&gt; Duplicate number index signature
            2375, // 2375 -&gt; Duplicate string index signature
          ]
        }
      },
      { test: /\.json$/, loader: 'raw' },
      { test: /\.html$/, loader: 'raw' },
      { test: /\.css$/, loader: 'raw!postcss' },
      { test: /\.less$/, loSWE: 'raw!postcss!less' }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({ template: 'client/index.html', filename: 'index.html' }),
    new Webpack.optimize.CommonsChunkPlugin('common', 'common.bundle.js')
  ]
};
</code></pre>