Make ReactReduxSpa able to do prerendering without node_modules at runtime

This commit is contained in:
SteveSandersonMS
2016-11-28 17:28:08 +00:00
parent 9cfea61f1e
commit a3cba50e88
4 changed files with 72 additions and 21 deletions

View File

@@ -2,9 +2,7 @@ var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var nodeExternals = require('webpack-node-externals');
var merge = require('webpack-merge');
var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;
// Configuration in common to both client-side and server-side bundles
var sharedConfig = () => ({
@@ -53,14 +51,22 @@ var clientBundleConfig = merge(sharedConfig(), {
// Configuration for server-side (prerendering) bundle suitable for running in Node
var serverBundleConfig = merge(sharedConfig(), {
resolve: { packageMains: ['main'] },
entry: { 'main-server': './ClientApp/boot-server.tsx' },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./ClientApp/dist/vendor-manifest.json'),
sourceType: 'commonjs2',
name: './vendor'
})
],
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
devtool: 'inline-source-map',
externals: [nodeExternals({ whitelist: [allFilenamesExceptJavaScript] })] // Don't bundle .js files from node_modules
devtool: 'inline-source-map'
});
module.exports = [clientBundleConfig, serverBundleConfig];