-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
55 lines (52 loc) · 1.68 KB
/
webpack.config.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import webpack from 'webpack';
import path from 'path';
export const baseConfig = {
entry: {
client: [
'babel-polyfill',
'./src/client/client.js',
],
host: [
'babel-polyfill',
'./src/host/host.js',
],
hostQuestion: [
'babel-polyfill',
'./src/host/hostQuestion.js',
],
vendors: ['react'],
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
},
module: {
loaders: [
{ test: /\.jsx?$/, loader: 'babel', exclude: /node_modules/ },
{ test: require.resolve('react'), loader: 'expose?React' },
{ test: /\.svg$/, loader: 'file?name=[path][name].[ext]&context=./static' },
{ test: /\.sass$/, loaders: ["style", "css", "sass"] },
],
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendor.js'),
],
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
devServer: {
historyApiFallback: {}, // truthy value required to allow react-router: webpack-dev-server will return 404s, but then the browser will fall back to the history API for routes
},
plugins: [],
};
const webpackClientUrl = 'webpack-dev-server/client?http://localhost:3000'; // port must match port where the dev server is running
// development config
export default {
...baseConfig,
devtool: 'eval',
entry: {
...baseConfig.entry,
client: [webpackClientUrl, ...baseConfig.entry.client],
host: [webpackClientUrl, ...baseConfig.entry.host],
},
};