forked from cytoscape/cytoscape.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
59 lines (55 loc) · 1.36 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
var env = function( name, def ){
var val = process.env[ name ];
if( val === undefined || val === '' ){
return def;
} else {
return val;
}
};
var boolEnv = function( name, def ){
return env( name, def ) == 'true';
};
var FILENAME = env('FILENAME', 'cytoscape.js');
var NODE_ENV = env('NODE_ENV', '');
var MINIFY = boolEnv('MINIFY', false);
var BABEL = boolEnv('BABEL', true);
var SOURCEMAPS = boolEnv('SOURCEMAPS', false);
var pkg = require('./package.json');
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: FILENAME,
library: 'cytoscape',
libraryTarget: 'umd'
},
externals: NODE_ENV === 'production' ? Object.keys( pkg.dependencies || {} ) : [],
module: {
rules: [ // common rules
].concat( BABEL ? [
{
loader: 'babel-loader',
test: /\.js$/,
include: [
path.resolve(__dirname, 'src')
],
exclude: [
path.resolve(__dirname, 'node_modules')
]
}
] : [])
},
plugins: [ // common plugins
].concat( MINIFY ? [ // minify plugins
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false,
}
})
] : [] ),
devtool: SOURCEMAPS ? 'inline-source-map' : false,
node: false
};