2018-01-18 00:00:03 +01:00
|
|
|
const Path = require('path');
|
2018-02-21 17:05:41 +01:00
|
|
|
const nodeExternals = require('webpack-node-externals');
|
2018-01-18 00:00:03 +01:00
|
|
|
const REACT_ROOT = Path.resolve(__dirname, 'react/');
|
2017-12-28 20:51:03 +01:00
|
|
|
|
2018-02-21 17:05:41 +01:00
|
|
|
console.log('REACT_ROOT:', REACT_ROOT);
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
{
|
2018-02-21 22:33:08 +01:00
|
|
|
target: 'web',
|
|
|
|
entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
|
|
|
|
output: {
|
|
|
|
path : Path.join(__dirname, 'public/bundle/'),
|
|
|
|
publicPath: 'public/bundle/',
|
|
|
|
filename : 'bundle.js',
|
|
|
|
},
|
|
|
|
watch : true,
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test : /.jsx?$/,
|
|
|
|
loader : 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
query : {
|
|
|
|
presets: ['es2015', 'react', 'stage-2'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [
|
|
|
|
REACT_ROOT,
|
|
|
|
'node_modules',
|
|
|
|
__dirname,
|
|
|
|
],
|
|
|
|
extensions: ['.js', '.jsx', '.scss'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'node',
|
|
|
|
node : {
|
|
|
|
__dirname: false,
|
|
|
|
},
|
2018-02-21 21:24:23 +01:00
|
|
|
externals: [nodeExternals()],
|
2018-02-22 19:48:46 +01:00
|
|
|
entry : ['babel-polyfill', 'whatwg-fetch', './server.js'],
|
2018-02-21 17:05:41 +01:00
|
|
|
output : {
|
2018-02-21 21:24:23 +01:00
|
|
|
path : Path.resolve(__dirname),
|
|
|
|
publicPath: '/',
|
|
|
|
filename : 'serverBundle.js',
|
2018-02-21 17:05:41 +01:00
|
|
|
},
|
|
|
|
watch : true,
|
|
|
|
module: {
|
2018-02-21 19:53:36 +01:00
|
|
|
rules: [
|
2018-02-21 17:05:41 +01:00
|
|
|
{
|
2018-02-21 19:53:36 +01:00
|
|
|
test : /.jsx?$/,
|
2018-02-21 17:05:41 +01:00
|
|
|
exclude: /node_modules/,
|
2018-02-21 19:53:36 +01:00
|
|
|
loader : 'babel-loader',
|
|
|
|
options: {
|
2018-02-21 21:24:23 +01:00
|
|
|
presets: ['es2015', 'react', 'stage-2'],
|
2018-02-21 17:05:41 +01:00
|
|
|
},
|
|
|
|
},
|
2018-02-21 19:53:36 +01:00
|
|
|
{
|
|
|
|
test : /.css$/,
|
|
|
|
loader: 'css-loader',
|
|
|
|
},
|
2018-02-21 17:05:41 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [
|
2018-02-21 21:24:23 +01:00
|
|
|
REACT_ROOT,
|
2018-02-21 17:05:41 +01:00
|
|
|
'node_modules',
|
|
|
|
__dirname,
|
|
|
|
],
|
2018-02-21 19:53:36 +01:00
|
|
|
extensions: ['.js', '.json', '.jsx', '.css'],
|
2018-02-21 17:05:41 +01:00
|
|
|
},
|
2018-01-18 00:00:03 +01:00
|
|
|
},
|
2018-02-21 17:05:41 +01:00
|
|
|
];
|