From 0d7aea377a3544693d3505eaa7a1ce6ba9ca69ab Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Thu, 15 Jun 2017 21:08:42 -0500 Subject: [PATCH] Increase ES6 utilization in webpack.config.js --- webpack.config.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 0259e1d45..b7ef402f0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const process = require('process'); const webpack = require('webpack'); -const aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/'; +const aui_css = `${__dirname}/node_modules/@atlassian/aui/dist/aui/css/`; /** * The URL of the Jitsi Meet deployment to be proxy to in the context of @@ -15,11 +15,11 @@ const devServerProxyTarget const minimize = process.argv.indexOf('-p') !== -1 || process.argv.indexOf('--optimize-minimize') !== -1; -const node_modules = __dirname + '/node_modules/'; +const node_modules = `${__dirname}/node_modules/`; const plugins = [ new webpack.LoaderOptionsPlugin({ debug: !minimize, - minimize: minimize + minimize }) ]; const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/; @@ -146,21 +146,22 @@ const config = { __filename: true }, output: { - filename: '[name]' + (minimize ? '.min' : '') + '.js', + filename: `[name]${minimize ? '.min' : ''}.js`, libraryTarget: 'umd', - path: __dirname + '/build', + path: `${__dirname}/build`, publicPath: '/libs/', - sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map' + sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map` }, - plugins: plugins, + plugins, resolve: { alias: { - jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js' + jquery: `jquery/dist/jquery${minimize ? '.min' : ''}.js` }, aliasFields: [ 'browser' ], extensions: [ + // Webpack 2 broke haste-resolver-webpack-plugin and I could not fix // it. But given that there is resolve.extensions and the only // non-default extension we have is .web.js, drop @@ -232,24 +233,25 @@ module.exports = configs; * @returns {string|undefined} If the request is to be served by the proxy * target, undefined; otherwise, the path to the local file to be served. */ -function devServerProxyBypass(request) { - let path = request.path; - +function devServerProxyBypass({ path }) { // Use local files from the css and libs directories. if (path.startsWith('/css/')) { return path; } - if (configs.some(function (c) { + + const configs = module.exports; + + if ((Array.isArray(configs) ? configs : Array(configs)).some(c => { if (path.startsWith(c.output.publicPath)) { if (!minimize) { // Since webpack-dev-server is serving non-minimized // artifacts, serve them even if the minimized ones are // requested. - Object.keys(c.entry).some(function (e) { - var name = e + '.min.js'; + Object.keys(c.entry).some(e => { + const name = `${e}.min.js`; if (path.indexOf(name) !== -1) { - path = path.replace(name, e + '.js'); + path = path.replace(name, `${e}.js`); return true; }