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 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;
}