Created
June 17, 2018 14:44
-
-
Save drenther/3f1f648c369a1369ba9e5ce2db79b16f to your computer and use it in GitHub Desktop.
webpack config for react-basic-ssr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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