From fba190c82686e9c544d2ed5f1e186b13b6d4479f Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 6 Mar 2020 15:20:56 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20ServiceWorker=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BE=20appcache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/webpack.prod.config.js | 12 ++++++++++-- client/index.html.template | 9 ++++++++- package-lock.json | 5 ----- package.json | 1 - 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/build/webpack.prod.config.js b/build/webpack.prod.config.js index 83d885b5..9d6ed5f5 100644 --- a/build/webpack.prod.config.js +++ b/build/webpack.prod.config.js @@ -9,7 +9,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); -const AppCachePlugin = require('appcache-webpack-plugin'); +const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); const publicDir = path.resolve(__dirname, '../dist/tmp/public'); const clientDir = path.resolve(__dirname, '../client'); @@ -55,6 +55,14 @@ module.exports = merge(baseWpConfig, { filename: `${publicDir}/index.html` }), new CopyWebpackPlugin([{from: `${clientDir}/assets/*`, to: `${publicDir}/`, flatten: true}]), - new AppCachePlugin({exclude: ['../index.html']}) + new SWPrecacheWebpackPlugin({ + cacheId: 'liberama', + dontCacheBustUrlsMatching: /\.\w{8}\./, + filename: 'service-worker.js', + minify: true, + navigateFallback: '/index.html', + staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], + stripPrefix: publicDir, + }), ] }); diff --git a/client/index.html.template b/client/index.html.template index c338033a..61af1f59 100644 --- a/client/index.html.template +++ b/client/index.html.template @@ -1,11 +1,18 @@ - + +
diff --git a/package-lock.json b/package-lock.json index eef25496..5ee76fb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -937,11 +937,6 @@ } } }, - "appcache-webpack-plugin": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/appcache-webpack-plugin/-/appcache-webpack-plugin-1.4.0.tgz", - "integrity": "sha512-QA0D+3yJmpPk0CyfxYMOzhzV941rkTSjCnUEy2vS05GeqK+mMnBScQSB23lstvzYaFpkeWeLMO9RamtafhliYw==" - }, "append-field": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", diff --git a/package.json b/package.json index dc435959..d3306939 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ }, "dependencies": { "@quasar/extras": "^1.5.2", - "appcache-webpack-plugin": "^1.4.0", "axios": "^0.18.1", "base-x": "^3.0.8", "chardet": "^0.7.0",