Sfoglia il codice sorgente

Increase ES6 utilization in webpack.config.js

master
Lyubo Marinov 8 anni fa
parent
commit
0d7aea377a
1 ha cambiato i file con 17 aggiunte e 15 eliminazioni
  1. 17
    15
      webpack.config.js

+ 17
- 15
webpack.config.js Vedi File

@@ -3,7 +3,7 @@
3 3
 const process = require('process');
4 4
 const webpack = require('webpack');
5 5
 
6
-const aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/';
6
+const aui_css = `${__dirname}/node_modules/@atlassian/aui/dist/aui/css/`;
7 7
 
8 8
 /**
9 9
  * The URL of the Jitsi Meet deployment to be proxy to in the context of
@@ -15,11 +15,11 @@ const devServerProxyTarget
15 15
 const minimize
16 16
     = process.argv.indexOf('-p') !== -1
17 17
         || process.argv.indexOf('--optimize-minimize') !== -1;
18
-const node_modules = __dirname + '/node_modules/';
18
+const node_modules = `${__dirname}/node_modules/`;
19 19
 const plugins = [
20 20
     new webpack.LoaderOptionsPlugin({
21 21
         debug: !minimize,
22
-        minimize: minimize
22
+        minimize
23 23
     })
24 24
 ];
25 25
 const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
@@ -146,21 +146,22 @@ const config = {
146 146
         __filename: true
147 147
     },
148 148
     output: {
149
-        filename: '[name]' + (minimize ? '.min' : '') + '.js',
149
+        filename: `[name]${minimize ? '.min' : ''}.js`,
150 150
         libraryTarget: 'umd',
151
-        path: __dirname + '/build',
151
+        path: `${__dirname}/build`,
152 152
         publicPath: '/libs/',
153
-        sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
153
+        sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
154 154
     },
155
-    plugins: plugins,
155
+    plugins,
156 156
     resolve: {
157 157
         alias: {
158
-            jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js'
158
+            jquery: `jquery/dist/jquery${minimize ? '.min' : ''}.js`
159 159
         },
160 160
         aliasFields: [
161 161
             'browser'
162 162
         ],
163 163
         extensions: [
164
+
164 165
             // Webpack 2 broke haste-resolver-webpack-plugin and I could not fix
165 166
             // it. But given that there is resolve.extensions and the only
166 167
             // non-default extension we have is .web.js, drop
@@ -232,24 +233,25 @@ module.exports = configs;
232 233
  * @returns {string|undefined} If the request is to be served by the proxy
233 234
  * target, undefined; otherwise, the path to the local file to be served.
234 235
  */
235
-function devServerProxyBypass(request) {
236
-    let path = request.path;
237
-
236
+function devServerProxyBypass({ path }) {
238 237
     // Use local files from the css and libs directories.
239 238
     if (path.startsWith('/css/')) {
240 239
         return path;
241 240
     }
242
-    if (configs.some(function (c) {
241
+
242
+    const configs = module.exports;
243
+
244
+    if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
243 245
                 if (path.startsWith(c.output.publicPath)) {
244 246
                     if (!minimize) {
245 247
                         // Since webpack-dev-server is serving non-minimized
246 248
                         // artifacts, serve them even if the minimized ones are
247 249
                         // requested.
248
-                        Object.keys(c.entry).some(function (e) {
249
-                            var name = e + '.min.js';
250
+                        Object.keys(c.entry).some(e => {
251
+                            const name = `${e}.min.js`;
250 252
 
251 253
                             if (path.indexOf(name) !== -1) {
252
-                                path = path.replace(name, e + '.js');
254
+                                path = path.replace(name, `${e}.js`);
253 255
 
254 256
                                 return true;
255 257
                             }

Loading…
Annulla
Salva