-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
69 lines (61 loc) · 1.62 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
var webpack = require('webpack');
var path = require('path');
var config = {
context: __dirname + '/src',
// the entry point of your library
entry: {
koto: './chart.js'
},
// where 3rd-party modules can reside
resolve: {
modulesDirectories: ['node_modules', 'bower_components']
},
output: {
// where to put standalone build file
path: path.join(__dirname, 'dist'),
publicPath: '/dist/',
// the name of the standalone build file
filename: 'chart.js',
// the standalone build should be wrapped in UMD for interop
libraryTarget: 'umd',
// the name of your library in global scope
library: 'KotoBarChart'
},
externals: {
// Specify all libraries a user need to have in his app,
// but which can be loaded externally, e.g. from CDN
// or included separately with a <script> tag
'koto': {
root: 'Koto',
commonjs: 'koto',
commonjs2: 'koto',
amd: 'koto'
},
'd3': 'd3'
},
plugins: [
new webpack.DefinePlugin({
ON_DEV: process.env.NODE_ENV === 'development' || !process.env.NODE_ENV,
ON_TEST: process.env.NODE_ENV === 'test',
ON_PROD: process.env.NODE_ENV === 'production'
})
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel?stage=1&optional=runtime&loose=all',
exclude: /(node_modules|bower_components)/
}]
},
devtool: 'source-map',
devServer: {
contentBase: '',
noInfo: false, // --no-info option
hot: true,
inline: true
}
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = config;