forked from tbolis/react-sketch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.library.cfg.js
76 lines (70 loc) · 2.14 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
72
73
74
75
76
/*global __dirname, module*/
var path = require('path');
const IgnorePlugin = require('webpack/lib/IgnorePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const NoErrorsPlugin = require('webpack/lib/NoErrorsPlugin');
const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const OccurenceOrderPlugin = require('webpack/lib/optimize/OccurenceOrderPlugin');
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']
},
debug: false,
cache: true,
module: {
loaders: [
{
test: /\.(js|jsx)$/,
include: [srcPath],
exclude: /(node_modules|bower_components|lib)/,
loaders: ['babel']
}
]
},
plugins: [
new DedupePlugin(),
new UglifyJsPlugin({
compress: {
warnings: false
}
}),
new NoErrorsPlugin(),
new OccurenceOrderPlugin(),
new AggressiveMergingPlugin(),
new IgnorePlugin(new RegExp('^(fs|ipc)$')),
new DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
})
]
};