forked from couetilc/react-social-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
59 lines (48 loc) · 1.22 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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const EXAMPLES_DIR = path.resolve(__dirname, 'examples');
function isDirectory(dir) {
return fs.lstatSync(dir).isDirectory();
}
function buildEntries() {
return fs.readdirSync(EXAMPLES_DIR).reduce((entries, dir) => {
if (dir === 'build') {
return entries;
}
const isDraft = dir.charAt(0) === '_';
if (!isDraft && isDirectory(path.join(EXAMPLES_DIR, dir))) {
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js'); // eslint-disable-line
}
return entries;
}, {});
}
module.exports = {
entry: buildEntries(),
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: 'examples/__build__',
publicPath: '/__build__/',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: path.resolve(__dirname, 'node_modules'),
query: {
presets: ['es2015-loose', 'stage-0', 'react', 'react-optimize'],
plugins: ['transform-runtime'],
},
},
{
test: /\.json$/,
loader: 'json',
},
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('shared.js'),
],
};