-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
95 lines (83 loc) · 2.02 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
95
var webpack = require('webpack');
var path = require('path');
var glob = require("glob");
var entries = glob.sync(path.resolve('./demo/**/**/app.js'))
.reduce(function(result, item) {
result[item.replace(path.resolve('./') + '/', '').replace(/\.js?$/, '')] = item;
console.log(result);
return result;
}, {});
entries.map = './index.js';
module.exports = function(watch) {
var DEBUG = !!watch ? true : false;
var environment = DEBUG ? 'development' : 'production';
return {
entry: entries,
output: {
path: path.join(__dirname, 'watch/js'),
filename: '[name].js',
library: 'map',
libraryTarget: 'umd'
},
watch: DEBUG,
cache: DEBUG,
debug: DEBUG,
devtool: DEBUG ? '#inline-source-map' : false,
externals: [
{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
}
],
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/
}
],
noParse: [
path.resolve('node_modules/react')
/*
path.resolve('node_modules/react-draggable2')
*/
]
},
stats: {
colors: true,
reasons: DEBUG,
chunks: !DEBUG
},
resolve: {
extensions: ['', '.js', '.jsx']
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(environment)
}
})
].concat(DEBUG ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.AggressiveMergingPlugin()
])
};
};