-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
94 lines (92 loc) · 2.16 KB
/
webpack.config.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var Webpack = require('webpack');
var path = require('path');
var nodeModulesPath = path.resolve(__dirname, 'node_modules');
var buildPath = path.resolve(__dirname, 'public/build/');
var serverPath = path.resolve(__dirname, 'src/server', 'app.js');
var browserPath = path.resolve(__dirname, 'src/client', 'main.js');
var definePlugin = new Webpack.DefinePlugin({
__DEV__: JSON.stringify(
JSON.parse(process.env.BUILD_DEV || 'true')
),
__PROD__: JSON.stringify(
JSON.parse(process.env.BUILD_PROD || 'false')
)
});
module.exports = [
{
target: 'node',
devtool: 'source-map',
debug: true,
entry: {
app: [serverPath]
},
output: {
path: buildPath,
filename: 'server.js',
libraryTarget: 'umd'
},
externals: [/^[a-z\-0-9]+$/, 'react-router/lib/Location.js', 'react-dom/server'],
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.jsx?$/,
exclude: /nodeModulesPath/,
loader: 'babel'
},
{
test: /\.ejs$/,
loader: 'ejs-loader?variable=data'
}
]
},
resolve: {
extensions: ['', '.js', '.json', '.jsx'],
alias: {
'$history': 'history/lib/createLocation'
}
},
plugins: [definePlugin]
},
{
devtool: 'eval',
debug: true,
entry: {
app:['./src/client/main.js']
},
output: {
path: buildPath,
publicPath: '/build/',
filename: 'browser.js'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader',
exclude: /nodeModulesPath/
},
{
test: /\.jsx?$/,
exclude: /nodeModulesPath/,
loader: 'babel-loader'
},
{
test: /\.ejs$/,
loader: 'ejs-loader?variable=data',
exclude: /nodeModulesPath/
}
]
},
resolve: {
extensions: ['', '.js', '.json', '.jsx'],
alias: {
'$history':'history/lib/createBrowserHistory'
}
},
plugins: [new Webpack.NoErrorsPlugin(), definePlugin]
}
];