forked from tbolis/react-sketch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.library.cfg.js
71 lines (65 loc) · 1.96 KB
/
webpack.library.cfg.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
/*global __dirname, module*/
var path = require('path');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const NoEmitOnErrorsPlugin = require('webpack/lib/NoEmitOnErrorsPlugin');
const OccurrenceOrderPlugin = require('webpack/lib/optimize/OccurrenceOrderPlugin');
const AggressiveMergingPlugin = require('webpack/lib/optimize/AggressiveMergingPlugin');
const srcPath = path.join(__dirname, 'src');
function containsObject(obj, list) {
var i;
for (i = 0; i < list.length; i++) {
if (list[i] === obj) {
return true;
}
}
return false;
}
const externals = [];
const explicitExternals = [];
const internals = ['fabric', 'canvas'];
Object.keys(require('./package.json').devDependencies).forEach(function (k) {
if (!containsObject(k, internals)) externals.push(k);
});
module.exports = {
entry: {
src: './src'
},
output: {
path: path.join(__dirname, 'lib'),
filename: 'index.js',
libraryTarget: 'umd'
},
//Every non-relative module is external apart from those given.
//externals: [/^(?!fabric|canvas|base64-js|ieee754|isarray|jsdom|xmldom)[a-z\-0-9]+$/],
externals: explicitExternals.concat(externals),
resolve: {
extensions: ['.js', '.jsx']
},
cache: true,
module: {
loaders: [
{
test: /\.(js|jsx)$/,
include: [srcPath],
exclude: /(node_modules|bower_components|lib)/,
loaders: ['babel-loader']
}
]
},
plugins: [
new UglifyJsPlugin({
compress: {
warnings: false
}
}),
new NoEmitOnErrorsPlugin(),
new OccurrenceOrderPlugin(),
new AggressiveMergingPlugin(),
new DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
]
};