diff --git a/src/scripts/settings/webSettings.js b/src/scripts/settings/webSettings.js index ca67b72cc5..517b7fe0e2 100644 --- a/src/scripts/settings/webSettings.js +++ b/src/scripts/settings/webSettings.js @@ -71,6 +71,11 @@ export function getIncludeCorsCredentials() { } export function getMultiServer() { + // Enable multi-server support when served by webpack + if (__WEBPACK_SERVE__) { // eslint-disable-line no-undef + return Promise.resolve(true); + } + return getConfig().then(config => { return !!config.multiserver; }).catch(error => { diff --git a/src/serviceworker.js b/src/serviceworker.js index 770f5de5c0..ca4ea5efe8 100644 --- a/src/serviceworker.js +++ b/src/serviceworker.js @@ -44,9 +44,8 @@ self.addEventListener('notificationclick', function (event) { event.waitUntil(executeAction(action, data, serverId)); }, false); -// Do not precache files in development so live reload works as expected -/* eslint-disable-next-line no-undef -- NODE_ENV is replaced by webpack */ -if (process.env.NODE_ENV === 'production') { +// Do not precache files when running with webpack dev server so live reload works as expected +if (!__WEBPACK_SERVE__) { // eslint-disable-line no-undef // this is needed by the webpack Workbox plugin /* eslint-disable-next-line no-restricted-globals,no-undef */ precacheAndRoute(self.__WB_MANIFEST); diff --git a/webpack.common.js b/webpack.common.js index b09bb95351..99f7272fd3 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -2,6 +2,7 @@ const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const { DefinePlugin } = require('webpack'); const Assets = [ 'native-promise-only/npo.js', @@ -30,6 +31,9 @@ module.exports = { ] }, plugins: [ + new DefinePlugin({ + __WEBPACK_SERVE__: JSON.stringify(!!process.env.WEBPACK_SERVE) + }), new CleanWebpackPlugin(), new HtmlWebpackPlugin({ filename: 'index.html',