Browse Source

Prepare for webpack 2

The configuration of webpack 1 does not fully work on webpack 2 without
modifications.

Unfortunately, webpack 2 produces a larger jitsi-meet bundle at this
time. Since the webpack version of lib-jitsi-meet is restrained by the
webpack version of jitsi-meet, we cannot move to webpack 2 right now.
dev1
Lyubomir Marinov 8 years ago
parent
commit
28ffb82f16
1 changed files with 25 additions and 3 deletions
  1. 25
    3
      webpack.config.js

+ 25
- 3
webpack.config.js View File

2
 
2
 
3
 var child_process = require('child_process'); // eslint-disable-line camelcase
3
 var child_process = require('child_process'); // eslint-disable-line camelcase
4
 var process = require('process');
4
 var process = require('process');
5
+var webpack = require('webpack');
5
 
6
 
6
 var minimize
7
 var minimize
7
     = process.argv.indexOf('-p') !== -1
8
     = process.argv.indexOf('-p') !== -1
8
         || process.argv.indexOf('--optimize-minimize') !== -1;
9
         || process.argv.indexOf('--optimize-minimize') !== -1;
10
+var plugins = [];
11
+
12
+if (minimize) {
13
+    // While webpack will automatically insert UglifyJsPlugin when minimize is
14
+    // true, the defaults of UglifyJsPlugin in webpack 1 and webpack 2 are
15
+    // different. Explicitly state what we want even if we want defaults in
16
+    // order to prepare for webpack 2.
17
+    plugins.push(new webpack.optimize.UglifyJsPlugin({
18
+        compress: {
19
+            // It is nice to see warnings from UglifyJsPlugin that something is
20
+            // unused and, consequently, is removed. The default is false in
21
+            // webpack 2.
22
+            warnings: true
23
+        },
24
+
25
+        // Use the source map to map error message locations to modules. The
26
+        // default is false in webpack 2.
27
+        sourceMap: true
28
+    }));
29
+}
9
 
30
 
10
 module.exports = {
31
 module.exports = {
11
     devtool: 'source-map',
32
     devtool: 'source-map',
16
         loaders: [ {
37
         loaders: [ {
17
             // Version this build of the lib-jitsi-meet library.
38
             // Version this build of the lib-jitsi-meet library.
18
 
39
 
19
-            loader: 'string-replace',
40
+            loader: 'string-replace-loader',
20
             query: {
41
             query: {
21
                 flags: 'g',
42
                 flags: 'g',
22
                 replace:
43
                 replace:
40
                 __dirname + '/modules/RTC/adapter.screenshare.js',
61
                 __dirname + '/modules/RTC/adapter.screenshare.js',
41
                 __dirname + '/node_modules/'
62
                 __dirname + '/node_modules/'
42
             ],
63
             ],
43
-            loader: 'babel',
64
+            loader: 'babel-loader',
44
             query: {
65
             query: {
45
                 presets: [
66
                 presets: [
46
                     'es2015'
67
                     'es2015'
60
         library: 'JitsiMeetJS',
81
         library: 'JitsiMeetJS',
61
         libraryTarget: 'umd',
82
         libraryTarget: 'umd',
62
         sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
83
         sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
63
-    }
84
+    },
85
+    plugins: plugins
64
 };
86
 };

Loading…
Cancel
Save