|
@@ -1,90 +1,94 @@
|
1
|
1
|
/* global __dirname */
|
2
|
2
|
|
3
|
3
|
const process = require('process');
|
|
4
|
+const { ProvidePlugin } = require('webpack');
|
4
|
5
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
5
|
6
|
|
6
|
|
-const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
|
7
|
7
|
|
8
|
|
-const minimize
|
9
|
|
- = process.argv.indexOf('-p') !== -1
|
10
|
|
- || process.argv.indexOf('--optimize-minimize') !== -1;
|
|
8
|
+module.exports = (minimize, analyzeBundle) => {
|
|
9
|
+ return {
|
|
10
|
+ // The inline-source-map is used to allow debugging the unit tests with Karma
|
|
11
|
+ devtool: minimize ? 'source-map' : 'inline-source-map',
|
|
12
|
+ mode: minimize ? 'production' : 'development',
|
|
13
|
+ module: {
|
|
14
|
+ rules: [ {
|
|
15
|
+ // Version this build of the lib-jitsi-meet library.
|
11
|
16
|
|
12
|
|
-module.exports = {
|
13
|
|
- // The inline-source-map is used to allow debugging the unit tests with Karma
|
14
|
|
- devtool: minimize ? 'source-map' : 'inline-source-map',
|
15
|
|
- mode: minimize ? 'production' : 'development',
|
16
|
|
- module: {
|
17
|
|
- rules: [ {
|
18
|
|
- // Version this build of the lib-jitsi-meet library.
|
|
17
|
+ loader: 'string-replace-loader',
|
|
18
|
+ options: {
|
|
19
|
+ flags: 'g',
|
|
20
|
+ replace:
|
|
21
|
+ process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
|
|
22
|
+ search: '{#COMMIT_HASH#}'
|
|
23
|
+ },
|
|
24
|
+ test: `${__dirname}/JitsiMeetJS.js`
|
|
25
|
+ }, {
|
|
26
|
+ // Transpile ES2015 (aka ES6) to ES5.
|
19
|
27
|
|
20
|
|
- loader: 'string-replace-loader',
|
21
|
|
- options: {
|
22
|
|
- flags: 'g',
|
23
|
|
- replace:
|
24
|
|
- process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
|
25
|
|
- search: '{#COMMIT_HASH#}'
|
26
|
|
- },
|
27
|
|
- test: `${__dirname}/JitsiMeetJS.js`
|
28
|
|
- }, {
|
29
|
|
- // Transpile ES2015 (aka ES6) to ES5.
|
30
|
|
-
|
31
|
|
- loader: 'babel-loader',
|
32
|
|
- options: {
|
33
|
|
- presets: [
|
34
|
|
- [
|
35
|
|
- '@babel/preset-env',
|
|
28
|
+ exclude: [
|
|
29
|
+ new RegExp(`${__dirname}/node_modules/(?!@jitsi/js-utils)`)
|
|
30
|
+ ],
|
|
31
|
+ loader: 'babel-loader',
|
|
32
|
+ options: {
|
|
33
|
+ presets: [
|
|
34
|
+ [
|
|
35
|
+ '@babel/preset-env',
|
36
|
36
|
|
37
|
|
- // Tell babel to avoid compiling imports into CommonJS
|
38
|
|
- // so that webpack may do tree shaking.
|
39
|
|
- {
|
40
|
|
- modules: false,
|
|
37
|
+ // Tell babel to avoid compiling imports into CommonJS
|
|
38
|
+ // so that webpack may do tree shaking.
|
|
39
|
+ {
|
|
40
|
+ modules: false,
|
41
|
41
|
|
42
|
|
- // Specify our target browsers so no transpiling is
|
43
|
|
- // done unnecessarily. For browsers not specified
|
44
|
|
- // here, the ES2015+ profile will be used.
|
45
|
|
- targets: {
|
46
|
|
- chrome: 58,
|
47
|
|
- electron: 2,
|
48
|
|
- firefox: 54,
|
49
|
|
- safari: 11
|
|
42
|
+ // Specify our target browsers so no transpiling is
|
|
43
|
+ // done unnecessarily. For browsers not specified
|
|
44
|
+ // here, the ES2015+ profile will be used.
|
|
45
|
+ targets: {
|
|
46
|
+ chrome: 58,
|
|
47
|
+ electron: 2,
|
|
48
|
+ firefox: 54,
|
|
49
|
+ safari: 11
|
|
50
|
+ }
|
50
|
51
|
}
|
51
|
|
- }
|
|
52
|
+ ]
|
|
53
|
+ ],
|
|
54
|
+ plugins: [
|
|
55
|
+ '@babel/plugin-proposal-class-properties',
|
|
56
|
+ '@babel/plugin-proposal-optional-chaining',
|
|
57
|
+ '@babel/plugin-proposal-export-namespace-from',
|
|
58
|
+ '@babel/plugin-proposal-nullish-coalescing-operator'
|
52
|
59
|
]
|
53
|
|
- ],
|
54
|
|
- plugins: [
|
55
|
|
- '@babel/plugin-proposal-class-properties',
|
56
|
|
- '@babel/plugin-proposal-optional-chaining',
|
57
|
|
- '@babel/plugin-proposal-export-namespace-from',
|
58
|
|
- '@babel/plugin-proposal-nullish-coalescing-operator'
|
59
|
|
- ]
|
60
|
|
- },
|
61
|
|
- test: /\.js$/
|
62
|
|
- } ]
|
63
|
|
- },
|
64
|
|
- node: {
|
65
|
|
- // Allow the use of the real filename of the module being executed. By
|
66
|
|
- // default Webpack does not leak path-related information and provides a
|
67
|
|
- // value that is a mock (/index.js).
|
68
|
|
- __filename: true
|
69
|
|
- },
|
70
|
|
- optimization: {
|
71
|
|
- concatenateModules: minimize
|
72
|
|
- },
|
73
|
|
- output: {
|
74
|
|
- filename: `[name]${minimize ? '.min' : ''}.js`,
|
75
|
|
- path: process.cwd(),
|
76
|
|
- sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
|
77
|
|
- },
|
78
|
|
- performance: {
|
79
|
|
- hints: minimize ? 'error' : false,
|
80
|
|
- maxAssetSize: 750 * 1024,
|
81
|
|
- maxEntrypointSize: 750 * 1024
|
82
|
|
- },
|
83
|
|
- plugins: [
|
84
|
|
- analyzeBundle
|
85
|
|
- && new BundleAnalyzerPlugin({
|
86
|
|
- analyzerMode: 'disabled',
|
87
|
|
- generateStatsFile: true
|
88
|
|
- })
|
89
|
|
- ].filter(Boolean)
|
|
60
|
+ },
|
|
61
|
+ test: /\.js$/
|
|
62
|
+ } ]
|
|
63
|
+ },
|
|
64
|
+ node: {
|
|
65
|
+ // Allow the use of the real filename of the module being executed. By
|
|
66
|
+ // default Webpack does not leak path-related information and provides a
|
|
67
|
+ // value that is a mock (/index.js).
|
|
68
|
+ __filename: true
|
|
69
|
+ },
|
|
70
|
+ optimization: {
|
|
71
|
+ concatenateModules: minimize
|
|
72
|
+ },
|
|
73
|
+ output: {
|
|
74
|
+ filename: `[name]${minimize ? '.min' : ''}.js`,
|
|
75
|
+ sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
|
|
76
|
+ },
|
|
77
|
+ performance: {
|
|
78
|
+ hints: minimize ? 'error' : false,
|
|
79
|
+ maxAssetSize: 750 * 1024,
|
|
80
|
+ maxEntrypointSize: 750 * 1024
|
|
81
|
+ },
|
|
82
|
+ plugins: [
|
|
83
|
+ analyzeBundle
|
|
84
|
+ && new BundleAnalyzerPlugin({
|
|
85
|
+ analyzerMode: 'disabled',
|
|
86
|
+ generateStatsFile: true
|
|
87
|
+ }),
|
|
88
|
+ !minimize
|
|
89
|
+ && new ProvidePlugin({
|
|
90
|
+ process: 'process/browser'
|
|
91
|
+ })
|
|
92
|
+ ].filter(Boolean)
|
|
93
|
+ };
|
90
|
94
|
};
|