spee.ch/webpack.config.js

77 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-01-18 00:00:03 +01:00
const Path = require('path');
const nodeExternals = require('webpack-node-externals');
2018-01-18 00:00:03 +01:00
const REACT_ROOT = Path.resolve(__dirname, 'react/');
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()],
entry : ['babel-polyfill', 'whatwg-fetch', './server.js'],
output : {
2018-02-21 21:24:23 +01:00
path : Path.resolve(__dirname),
publicPath: '/',
filename : 'serverBundle.js',
},
watch : true,
module: {
2018-02-21 19:53:36 +01:00
rules: [
{
2018-02-21 19:53:36 +01:00
test : /.jsx?$/,
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 19:53:36 +01:00
{
test : /.css$/,
loader: 'css-loader',
},
],
},
resolve: {
modules: [
2018-02-21 21:24:23 +01:00
REACT_ROOT,
'node_modules',
__dirname,
],
2018-02-21 19:53:36 +01:00
extensions: ['.js', '.json', '.jsx', '.css'],
},
2018-01-18 00:00:03 +01:00
},
];