-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
46 lines (37 loc) · 950 Bytes
/
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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const CODE = __dirname+'/sampleApp';
module.exports = {
devtool: 'eval',
entry: fs.readdirSync(CODE).reduce(function (entries, dir) {
if (isDirectory(path.join(CODE, dir)))
entries[dir] = path.join(CODE, 'routes.js');
return entries;
}, {}),
output: {
path: 'sampleApp/__build__',
filename: 'routes.js',
chunkFilename: '[id].chunk.js',
publicPath: '/__build__/'
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader',
query: {
presets:['es2015','react']
}
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('shared.js')
],
resolve: {
extensions: ['', '.js', '.jsx']
},
};
function isDirectory(dir) {
return fs.lstatSync(dir).isDirectory();
}