forked from jitsi/lib-jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
87 lines (79 loc) · 2.37 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
/* global __dirname */
const process = require('process');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
const minimize
= process.argv.indexOf('-p') !== -1
|| process.argv.indexOf('--optimize-minimize') !== -1;
const plugins = [
new webpack.LoaderOptionsPlugin({
debug: !minimize,
minimize
})
];
if (minimize) {
plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
plugins.push(new UglifyJsPlugin({
cache: true,
extractComments: true,
parallel: true,
sourceMap: true
}));
}
const config = {
devtool: 'source-map',
module: {
rules: [ {
// Version this build of the lib-jitsi-meet library.
loader: 'string-replace-loader',
options: {
flags: 'g',
replace:
process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
search: '{#COMMIT_HASH#}'
},
test: `${__dirname}/JitsiMeetJS.js`
}, {
// Transpile ES2015 (aka ES6) to ES5.
exclude: [
`${__dirname}/modules/RTC/adapter.screenshare.js`,
new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
],
loader: 'babel-loader',
options: {
presets: [
[
'env',
// Tell babel to avoid compiling imports into CommonJS
// so that webpack may do tree shaking.
{ modules: false }
],
'stage-1'
]
},
test: /\.js$/
} ]
},
node: {
// Allow the use of the real filename of the module being executed. By
// default Webpack does not leak path-related information and provides a
// value that is a mock (/index.js).
__filename: true
},
output: {
filename: `[name]${minimize ? '.min' : ''}.js`,
sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
},
plugins
};
module.exports = [
Object.assign({}, config, {
entry: {
'lib-jitsi-meet': './index.js'
},
output: Object.assign({}, config.output, {
library: 'JitsiMeetJS',
libraryTarget: 'umd'
})
})
];