diff --git a/client/.babelrc b/client/.babelrc index 63b1c53de..60be246eb 100644 --- a/client/.babelrc +++ b/client/.babelrc @@ -11,4 +11,4 @@ "transform-async-to-generator", "transform-react-jsx" ] -} +} \ No newline at end of file diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index 64c274660..dd44e72cd 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -267,6 +267,11 @@ Talk.render = function(el, opts) { console.warn( 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' ); + + if (!window.location.origin) { + window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; + } + query.asset_url = window.location.origin + window.location.pathname; } } diff --git a/docs/_docs/02-01-configuration.md b/docs/_docs/02-01-configuration.md index d35257983..d2e990375 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 1b3c4b763..873d20472 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -33,6 +33,7 @@ const buildEmbeds = [ const config = { devtool: 'cheap-module-source-map', + target: 'web', output: { path: path.join(__dirname, 'dist'), publicPath: '/client/', @@ -153,11 +154,15 @@ 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] = [ - 'babel-polyfill', - path - ]; + entry: entries.reduce((entry, {name, path, disablePolyfill = false}) => { + if (disablePolyfill) { + entry[name] = path; + } else { + entry[name] = [ + 'babel-polyfill', + path + ]; + } return entry; }, {}) @@ -171,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' } ], { @@ -183,7 +189,7 @@ module.exports = [ // All framework targets/embeds/plugins. applyConfig([ - // // Load in all the targets. + // Load in all the targets. ...buildTargets.map((target) => ({ name: `${target}/bundle`, path: path.join(__dirname, 'client/', target, '/src/index')