From c522ff3ddab7ed8e3a128dd6edd2cd6902226e99 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Sat, 26 Oct 2019 06:48:06 -0400 Subject: [PATCH 1/2] fix: update script-tag output to include config from default.js instead of hardcoded config --- platform/viewer/.webpack/webpack.commonjs.js | 12 +++++++++++ .../public/html-templates/script-tag.html | 21 ++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/platform/viewer/.webpack/webpack.commonjs.js b/platform/viewer/.webpack/webpack.commonjs.js index 8ae080693..58364c388 100644 --- a/platform/viewer/.webpack/webpack.commonjs.js +++ b/platform/viewer/.webpack/webpack.commonjs.js @@ -12,7 +12,9 @@ const SRC_DIR = path.join(__dirname, '../src'); const DIST_DIR = path.join(__dirname, '../dist'); const PUBLIC_DIR = path.join(__dirname, '../public'); // ~~ Env Vars +const APP_CONFIG = process.env.APP_CONFIG || 'config/default.js'; const HTML_TEMPLATE = process.env.HTML_TEMPLATE || 'script-tag.html'; +const PUBLIC_URL = process.env.PUBLIC_URL || '/'; module.exports = (env, argv) => { const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR }); @@ -33,12 +35,22 @@ module.exports = (env, argv) => { plugins: [ // Clean output.path new CleanWebpackPlugin(), + new CopyWebpackPlugin([ + // Copy over and rename our target app config file + { + from: `${PUBLIC_DIR}/${APP_CONFIG}`, + to: `${DIST_DIR}/app-config.js`, + }, + ]), // Generate "index.html" w/ correct includes/imports // NOTE: We use this for E2E Tests new HtmlWebpackPlugin({ inject: false, template: `${PUBLIC_DIR}/html-templates/${HTML_TEMPLATE}`, filename: 'index.html', + templateParameters: { + PUBLIC_URL: PUBLIC_URL, + }, }), new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1, diff --git a/platform/viewer/public/html-templates/script-tag.html b/platform/viewer/public/html-templates/script-tag.html index 766b4133e..455b63493 100644 --- a/platform/viewer/public/html-templates/script-tag.html +++ b/platform/viewer/public/html-templates/script-tag.html @@ -24,6 +24,7 @@
+