From a277a72f5749073216d728ff5963dcb3ed03a36a Mon Sep 17 00:00:00 2001 From: Alexey Rodionov Date: Fri, 16 Mar 2018 11:39:49 +0300 Subject: [PATCH] [PWA] (2/2) Add service worker --- config/webpack.prod.js | 6 ++++++ index.html | 9 +++++++++ package.json | 16 ++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/config/webpack.prod.js b/config/webpack.prod.js index e4b32ac3..b4997d5c 100644 --- a/config/webpack.prod.js +++ b/config/webpack.prod.js @@ -1,6 +1,7 @@ const webpack = require("webpack"); const merge = require("webpack-merge"); const common = require("./webpack.common.js"); +const workboxPlugin = require("workbox-webpack-plugin"); const config = merge(common, { devtool: "source-map", @@ -15,6 +16,11 @@ const config = merge(common, { }), new webpack.optimize.UglifyJsPlugin({ sourceMap: true + }), + new workboxPlugin.GenerateSW({ + swDest: "service-worker.js", + clientsClaim: true, + skipWaiting: true, }) ] }); diff --git a/index.html b/index.html index e7ebdf7f..f473c28a 100755 --- a/index.html +++ b/index.html @@ -43,6 +43,15 @@ + + + diff --git a/package.json b/package.json index b136838e..e181fa8c 100644 --- a/package.json +++ b/package.json @@ -13,17 +13,20 @@ "test": "jest --coverage", "travis-tests": "jest --coverage && npm run lint && npm run build", "tdd": "jest --watch", - "format": - "prettier --write experiments/**/*.js js/**/*.js css/**/*.css webpack.config.js webpack.production.config.js", - "build-skin": - "rm skins/base-2.91.wsz && cd skins/base-2.91 && zip -x .* -x 'Skining Updates.txt' -r ../base-2.91.wsz .", + "format": "prettier --write experiments/**/*.js js/**/*.js css/**/*.css webpack.config.js webpack.production.config.js", + "build-skin": "rm skins/base-2.91.wsz && cd skins/base-2.91 && zip -x .* -x 'Skining Updates.txt' -r ../base-2.91.wsz .", "skin-info": "unzip -vl skins/base-2.91.wsz" }, "repository": { "type": "git", "url": "git+https://github.com/captbaritone/winamp2-js.git" }, - "keywords": ["Winamp", "HTML5", "audio", "web-audio-api"], + "keywords": [ + "Winamp", + "HTML5", + "audio", + "web-audio-api" + ], "author": "Jordan Eldredge ", "license": "MIT", "bugs": { @@ -53,7 +56,8 @@ "style-loader": "^0.19.1", "travis-weigh-in": "^1.0.2", "url-loader": "^0.6.2", - "webpack-dev-server": "^2.7.1" + "webpack-dev-server": "^2.7.1", + "workbox-webpack-plugin": "^3.0.0" }, "dependencies": { "babel": "^6.23.0",