Increase ES6 utilization in webpack.config.js

This commit is contained in:
Lyubo Marinov 2017-06-15 21:08:42 -05:00
parent 617df1c69c
commit 0d7aea377a
1 changed files with 17 additions and 15 deletions

View File

@ -3,7 +3,7 @@
const process = require('process'); const process = require('process');
const webpack = require('webpack'); 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 * The URL of the Jitsi Meet deployment to be proxy to in the context of
@ -15,11 +15,11 @@ const devServerProxyTarget
const minimize const minimize
= process.argv.indexOf('-p') !== -1 = process.argv.indexOf('-p') !== -1
|| process.argv.indexOf('--optimize-minimize') !== -1; || process.argv.indexOf('--optimize-minimize') !== -1;
const node_modules = __dirname + '/node_modules/'; const node_modules = `${__dirname}/node_modules/`;
const plugins = [ const plugins = [
new webpack.LoaderOptionsPlugin({ new webpack.LoaderOptionsPlugin({
debug: !minimize, debug: !minimize,
minimize: minimize minimize
}) })
]; ];
const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/; const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
@ -146,21 +146,22 @@ const config = {
__filename: true __filename: true
}, },
output: { output: {
filename: '[name]' + (minimize ? '.min' : '') + '.js', filename: `[name]${minimize ? '.min' : ''}.js`,
libraryTarget: 'umd', libraryTarget: 'umd',
path: __dirname + '/build', path: `${__dirname}/build`,
publicPath: '/libs/', publicPath: '/libs/',
sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map' sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
}, },
plugins: plugins, plugins,
resolve: { resolve: {
alias: { alias: {
jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js' jquery: `jquery/dist/jquery${minimize ? '.min' : ''}.js`
}, },
aliasFields: [ aliasFields: [
'browser' 'browser'
], ],
extensions: [ extensions: [
// Webpack 2 broke haste-resolver-webpack-plugin and I could not fix // Webpack 2 broke haste-resolver-webpack-plugin and I could not fix
// it. But given that there is resolve.extensions and the only // it. But given that there is resolve.extensions and the only
// non-default extension we have is .web.js, drop // 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 * @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. * target, undefined; otherwise, the path to the local file to be served.
*/ */
function devServerProxyBypass(request) { function devServerProxyBypass({ path }) {
let path = request.path;
// Use local files from the css and libs directories. // Use local files from the css and libs directories.
if (path.startsWith('/css/')) { if (path.startsWith('/css/')) {
return path; 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 (path.startsWith(c.output.publicPath)) {
if (!minimize) { if (!minimize) {
// Since webpack-dev-server is serving non-minimized // Since webpack-dev-server is serving non-minimized
// artifacts, serve them even if the minimized ones are // artifacts, serve them even if the minimized ones are
// requested. // requested.
Object.keys(c.entry).some(function (e) { Object.keys(c.entry).some(e => {
var name = e + '.min.js'; const name = `${e}.min.js`;
if (path.indexOf(name) !== -1) { if (path.indexOf(name) !== -1) {
path = path.replace(name, e + '.js'); path = path.replace(name, `${e}.js`);
return true; return true;
} }