Expose build type on window (#630)

* Expose build type on window

* Build two panels for Hass.io
This commit is contained in:
Paulus Schoutsen 2017-11-14 22:39:20 -08:00 committed by GitHub
parent de87c5b19b
commit 6fac4e9027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,7 @@
"globals": {
"__DEV__": false,
"__DEMO__": false,
"__BUILD__": false,
"Polymer": true,
"webkitSpeechRecognition": false,
},

View File

@ -37,7 +37,7 @@ async function buildHassioPanel(es6) {
});
return minifyStream(stream, es6)
.pipe(rename('hassio-main.html'))
.pipe(rename(`hassio-main-${es6 ? 'latest' : 'es5'}.html`))
.pipe(gulp.dest('build-temp'));
}

View File

@ -3,10 +3,11 @@ import * as HAWS from 'home-assistant-js-websocket';
window.HAWS = HAWS;
window.HASS_DEMO = __DEMO__;
window.HASS_DEV = __DEV__;
window.HASS_BUILD = __BUILD__;
const init = window.createHassConnection = function (password) {
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
const url = `${proto}://${window.location.host}/api/websocket${window.location.search}`;
const url = `${proto}://${window.location.host}/api/websocket?${window.HASS_BUILD}`;
const options = {
setupRetry: 10,
};

View File

@ -39,7 +39,7 @@ class HaPanelHassio extends Polymer.Element {
connectedCallback() {
super.connectedCallback();
if (!window.HASS_DEV) {
Polymer.importHref('/api/hassio/panel', null, () => {
Polymer.importHref(`/api/hassio/panel_${window.HASS_BUILD}`, null, () => {
// eslint-disable-next-line
alert('Failed to load the Hass.io panel from supervisor.');
});

View File

@ -31,6 +31,7 @@ const plugins = [
values: {
__DEV__: JSON.stringify(DEV),
__DEMO__: JSON.stringify(DEMO),
__BUILD__: JSON.stringify('latest'),
},
}),
];

View File

@ -41,6 +41,7 @@ const plugins = [
values: {
__DEV__: JSON.stringify(DEV),
__DEMO__: JSON.stringify(DEMO),
__BUILD__: JSON.stringify('es5'),
},
}),
];