diff --git a/build/service-worker-prod.js b/build/service-worker-prod.js
index 1179ec20..8b8493e6 100644
--- a/build/service-worker-prod.js
+++ b/build/service-worker-prod.js
@@ -4,7 +4,7 @@
// Check to make sure service workers are supported in the current browser,
// and that the current page is accessed from a secure origin. Using a
// service worker from an insecure origin will trigger JS console errors.
- const isLocalhost = Boolean(window.location.hostname === 'localhost' ||
+ var isLocalhost = Boolean(window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
@@ -26,7 +26,7 @@
// i.e. whether there's an existing service worker.
if (navigator.serviceWorker.controller) {
// The updatefound event implies that registration.installing is set
- const installingWorker = registration.installing;
+ var installingWorker = registration.installing;
installingWorker.onstatechange = function() {
switch (installingWorker.state) {
diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js
index 7b4b21c4..9751b880 100644
--- a/build/webpack.prod.conf.js
+++ b/build/webpack.prod.conf.js
@@ -84,8 +84,16 @@ var webpackConfig = merge(baseWebpackConfig, {
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency',
- serviceWorkerLoader: ``
+ serviceWorkerLoader: (() => {
+ let sw = fs.readFileSync(path.join(__dirname, './service-worker-prod.js'), 'utf-8')
+
+ let result = UglifyJS.minify(sw)
+ if (result.error == null) {
+ sw = result.code
+ }
+
+ return ''
+ })()
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({