diff --git a/build-scripts/gulp/service-worker.js b/build-scripts/gulp/service-worker.js
index dd46b6f1d2..01e7a97323 100644
--- a/build-scripts/gulp/service-worker.js
+++ b/build-scripts/gulp/service-worker.js
@@ -19,6 +19,8 @@ gulp.task("gen-service-worker-app-dev", (done) => {
console.debug('Service worker disabled in development');
self.addEventListener('install', (event) => {
+ // This will activate the dev service worker,
+ // removing any prod service worker the dev might have running
self.skipWaiting();
});
`
@@ -27,6 +29,28 @@ self.addEventListener('install', (event) => {
});
gulp.task("gen-service-worker-app-prod", async () => {
+ // Read bundled source file
+ const bundleManifestLatest = require(path.resolve(
+ paths.output,
+ "manifest.json"
+ ));
+ let serviceWorkerContent = fs.readFileSync(
+ paths.root + bundleManifestLatest["service_worker.js"],
+ "utf-8"
+ );
+
+ // Delete old file from frontend_latest so manifest won't pick it up
+ fs.removeSync(paths.root + bundleManifestLatest["service_worker.js"]);
+ fs.removeSync(paths.root + bundleManifestLatest["service_worker.js.map"]);
+
+ // Remove ES5
+ const bundleManifestES5 = require(path.resolve(
+ paths.output_es5,
+ "manifest.json"
+ ));
+ fs.removeSync(paths.root + bundleManifestES5["service_worker.js"]);
+ fs.removeSync(paths.root + bundleManifestES5["service_worker.js.map"]);
+
const workboxManifest = await workboxBuild.getManifest({
// Files that mach this pattern will be considered unique and skip revision check
// ignore JS files + translation files
@@ -37,7 +61,8 @@ gulp.task("gen-service-worker-app-prod", async () => {
"frontend_latest/*.js",
// Cache all English translations because we catch them as fallback
// Using pattern to match hash instead of * to avoid caching en-GB
- "static/translations/**/en-+([a-f0-9]).json",
+ // 'v' added as valid hash letter because in dev we hash with 'dev'
+ "static/translations/**/en-+([a-fv0-9]).json",
// Icon shown on splash screen
"static/icons/favicon-192x192.png",
"static/icons/favicon.ico",
@@ -53,20 +78,6 @@ gulp.task("gen-service-worker-app-prod", async () => {
console.warn(warning);
}
- // Replace `null` with 0 for better compression
- for (const entry of workboxManifest.manifestEntries) {
- if (entry.revision === null) {
- entry.revision = 0;
- }
- }
-
- const manifest = require(path.resolve(paths.output, "manifest.json"));
-
- // Write bundled source file
- let serviceWorkerContent = fs.readFileSync(
- paths.root + manifest["service_worker.js"],
- "utf-8"
- );
// remove source map and add WB manifest
serviceWorkerContent = sourceMapUrl.removeFrom(serviceWorkerContent);
serviceWorkerContent = serviceWorkerContent.replace(
@@ -76,8 +87,4 @@ gulp.task("gen-service-worker-app-prod", async () => {
// Write new file to root
fs.writeFileSync(swDest, serviceWorkerContent);
-
- // Delete old file from frontend_latest
- fs.removeSync(paths.root + manifest["service_worker.js"]);
- fs.removeSync(paths.root + manifest["service_worker.js.map"]);
});
diff --git a/build-scripts/webpack.js b/build-scripts/webpack.js
index cdd7c4eb06..5cbb12bfea 100644
--- a/build-scripts/webpack.js
+++ b/build-scripts/webpack.js
@@ -20,7 +20,9 @@ const createWebpackConfig = ({
}
return {
mode: isProdBuild ? "production" : "development",
- devtool: isProdBuild ? "source-map" : "inline-cheap-module-source-map",
+ devtool: isProdBuild
+ ? "cheap-module-source-map"
+ : "eval-cheap-module-source-map",
entry,
module: {
rules: [
@@ -74,6 +76,10 @@ const createWebpackConfig = ({
/@polymer\/font-roboto\/roboto\.js$/,
path.resolve(paths.polymer_dir, "src/util/empty.js")
),
+ new webpack.NormalModuleReplacementPlugin(
+ /@vaadin\/vaadin-material-styles\/font-roboto\.js$/,
+ path.resolve(paths.polymer_dir, "src/util/empty.js")
+ ),
// Ignore mwc icons pointing at CDN.
new webpack.NormalModuleReplacementPlugin(
/@material\/mwc-icon\/mwc-icon-font\.js$/,
diff --git a/cast/src/launcher/layout/hc-connect.ts b/cast/src/launcher/layout/hc-connect.ts
index 9660f4755a..048a69f403 100644
--- a/cast/src/launcher/layout/hc-connect.ts
+++ b/cast/src/launcher/layout/hc-connect.ts
@@ -184,7 +184,7 @@ export class HcConnect extends LitElement {
this.castManager = null;
}
);
- registerServiceWorker(false);
+ registerServiceWorker(this, false);
}
private async _handleDemo() {
diff --git a/demo/script/size_stats b/demo/script/size_stats
index 3afbe6c9a0..6d785f36b3 100755
--- a/demo/script/size_stats
+++ b/demo/script/size_stats
@@ -7,5 +7,5 @@ set -e
cd "$(dirname "$0")/.."
STATS=1 NODE_ENV=production ../node_modules/.bin/webpack --profile --json > compilation-stats.json
-npx webpack-bundle-analyzer compilation-stats.json dist
+npx webpack-bundle-analyzer compilation-stats.json dist/frontend_latest
rm compilation-stats.json
diff --git a/setup.py b/setup.py
index 579608a0b0..ede0929337 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="home-assistant-frontend",
- version="20200513.0",
+ version="20200514.0",
description="The Home Assistant frontend",
url="https://github.com/home-assistant/home-assistant-polymer",
author="The Home Assistant Authors",
diff --git a/src/auth/ha-authorize.ts b/src/auth/ha-authorize.ts
index f811a21186..db9023efab 100644
--- a/src/auth/ha-authorize.ts
+++ b/src/auth/ha-authorize.ts
@@ -121,7 +121,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
const tempA = document.createElement("a");
tempA.href = this.redirectUri!;
if (tempA.host === location.host) {
- registerServiceWorker(false);
+ registerServiceWorker(this, false);
}
}
diff --git a/src/components/ha-cover-controls.js b/src/components/ha-cover-controls.js
index 781cc3c5b3..3cf69923d3 100644
--- a/src/components/ha-cover-controls.js
+++ b/src/components/ha-cover-controls.js
@@ -30,7 +30,7 @@ class HaCoverControls extends PolymerElement {
icon="hass:stop"
on-click="onStopTap"
invisible$="[[!entityObj.supportsStop]]"
- disabled="[[computStopDisabled(stateObj)]]"
+ disabled="[[computeStopDisabled(stateObj)]]"
>