Skip to content

Instantly share code, notes, and snippets.

@drenther
Created June 17, 2018 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drenther/3f1f648c369a1369ba9e5ce2db79b16f to your computer and use it in GitHub Desktop.
Save drenther/3f1f648c369a1369ba9e5ce2db79b16f to your computer and use it in GitHub Desktop.
webpack config for react-basic-ssr
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const common = {
rules: [{ test: /\.(js)$/, use: 'babel-loader' }],
};
const clientConfig = {
entry: './src/client/index.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js',
publicPath: '/',
},
module: common,
plugins: [
new webpack.DefinePlugin({
__isBrowser__: 'true',
}),
],
};
const serverConfig = {
entry: './src/server/index.js',
target: 'node',
externals: [nodeExternals()],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'server.js',
publicPath: '/',
},
module: common,
plugins: [
new webpack.DefinePlugin({
__isBrowser__: 'false',
}),
],
};
module.exports = [clientConfig, serverConfig];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment