-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.config.js
91 lines (82 loc) · 1.87 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
//this file could be massively improved.
//inspired by https://christianalfoni.github.io/react-webpack-cookbook/
//please do visit this link! Awesome.
var webpack = require('webpack');
var path = require('path');
var appDir = path.join(__dirname, 'apps');
var explDir = path.join(__dirname, 'example');
var licenseBanner = 'Thanks to all the providers of the components. See the respective' +
'github pages for their licenses.';
var outputPath, filename, entry, externals, output;
switch (process.env.NODE_ENV) {
case 'example':
outputPath = __dirname + '/example';
filename = 'bundle.js';
entry = ['webpack/hot/dev-server',
(
'./example/main.js'
)];
output = {
path: outputPath,
filename: filename
};
externals = [];
break;
case 'production':
outputPath = __dirname + '/dist';
filename = 'd3-react-squared.js';
entry = './apps/main.js';
output = {
path: outputPath,
library: 'd3-react-squared',
libraryTarget: 'umd',
filename: filename,
};
externals = [
{
react: 'react',
'react-dom': 'react-dom',
d3: 'd3',
}
];
break;
default:
outputPath = __dirname + '/dist';
filename = 'bundle.js';
entry = ['webpack/hot/dev-server',
(
'./example/main.js'
)];
output = {
path: outputPath,
filename: filename
};
externals = [];
}
var config = {
context: __dirname,
entry: entry,
output: output,
module: {
noParse: [],
loaders: [
{
test: /\.js$/,
include: [appDir, explDir],
loader: 'babel-loader',
},
],
preLoaders: [
{
test: /\.js$/,
include: [appDir, explDir],
loader: 'eslint',
},
],
},
externals: externals,
plugins: [
new webpack.BannerPlugin(licenseBanner),
],
};
module.exports = config;