Skip to content

Commit

Permalink
Prefer Flow developemnt mode over other checks (vaadin#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored and Artur- committed Jun 5, 2019
1 parent eedfd6f commit 5673bd3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions vaadin-development-mode-detector.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const DEV_MODE_CODE_REGEXP =
/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;

const FlowClients = window.Vaadin && window.Vaadin.Flow && window.Vaadin.Flow.clients;

function isMinified() {
function test() {
/** vaadin-dev-mode:start
Expand All @@ -15,7 +17,19 @@

function isDevelopmentMode() {
try {
return isForcedDevelopmentMode() || (isLocalhost() && !isMinified() && !isFlowProductionMode());
if (isForceDevelopmentMode()) {
return true;
}

if (!isLocalhost()) {
return false;
}

if (FlowClients) {
return !isFlowProductionMode();
}

return !isMinified();
} catch (e) {
// Some error in this code, assume production so no further actions will be taken
return false;
Expand All @@ -31,10 +45,10 @@
}

function isFlowProductionMode() {
if (window.Vaadin && window.Vaadin.Flow && window.Vaadin.Flow.clients) {
const productionModeApps = Object.keys(window.Vaadin.Flow.clients)
.map(key => window.Vaadin.Flow.clients[key])
.filter(client => client.productionMode);
if (FlowClients) {
const productionModeApps = Object.keys(FlowClients)
.map(key => FlowClients[key])
.filter(client => client.productionMode);
if (productionModeApps.length > 0) {
return true;
}
Expand Down

0 comments on commit 5673bd3

Please sign in to comment.