From de97ad59ec3a22d11f70a4d1f054140906c4835c Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 1 Aug 2017 19:14:26 +1000 Subject: [PATCH] Added configuration for the babel polyfill --- docs/_docs/02-01-configuration.md | 1 + webpack.config.js | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/_docs/02-01-configuration.md b/docs/_docs/02-01-configuration.md index ab644e5e3..fd2ee0478 100644 --- a/docs/_docs/02-01-configuration.md +++ b/docs/_docs/02-01-configuration.md @@ -45,6 +45,7 @@ These are only used during the webpack build. thread. (Default `3`) - `TALK_DEFAULT_STREAM_TAB` (_optional_) - specify the default stream tab in the admin. (Default `all`) +- `TALK_DISABLE_EMBED_POLYFILL` (_optional_) - when set to `TRUE`, the build process will not include the [babel-polyfill](https://babeljs.io/docs/usage/polyfill/) in the embed.js target. (Default `FALSE`) ### Database diff --git a/webpack.config.js b/webpack.config.js index 94d9ccc44..873d20472 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -154,8 +154,16 @@ if (process.env.NODE_ENV === 'production') { // Applies the base configuration to the following entries. const applyConfig = (entries, root = {}) => _.merge({}, config, { - entry: entries.reduce((entry, {name, path}) => { - entry[name] = path; + entry: entries.reduce((entry, {name, path, disablePolyfill = false}) => { + if (disablePolyfill) { + entry[name] = path; + } else { + entry[name] = [ + 'babel-polyfill', + path + ]; + } + return entry; }, {}) }, root); @@ -168,7 +176,8 @@ module.exports = [ // Load in the root embed. { name: 'embed', - path: path.join(__dirname, 'client/coral-embed/src/index') + path: path.join(__dirname, 'client/coral-embed/src/index'), + disablePolyfill: process.env.TALK_DISABLE_EMBED_POLYFILL === 'TRUE' } ], { @@ -189,10 +198,7 @@ module.exports = [ // Load in all the embeds. ...buildEmbeds.map((embed) => ({ name: `embed/${embed}/bundle`, - path: [ - 'babel-polyfill', - path.join(__dirname, 'client/', `coral-embed-${embed}`, '/src/index') - ] + path: path.join(__dirname, 'client/', `coral-embed-${embed}`, '/src/index') })), // Load in all the plugin entries.