From 01a063c56ae23639a7b3d7e88e00460e47a7e6fc Mon Sep 17 00:00:00 2001 From: Sarbik Betal <41508422+sarbikbetal@users.noreply.github.com> Date: Sat, 5 Sep 2020 01:11:11 +0530 Subject: [PATCH] Updated netlify docs for vue/cli-plugin-pwa Added a small fix related to PWAs deployed on Netlify. If you don't exclude the `_redirects` file, the service worker will try to ache it but it won't be able to find the file in the netlify servers and as a result the service worker installation will fail, which will break all the PWA functionalities --- docs/guide/deployment.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/guide/deployment.md b/docs/guide/deployment.md index c5b4108f2c..41a3c945bf 100644 --- a/docs/guide/deployment.md +++ b/docs/guide/deployment.md @@ -145,7 +145,7 @@ Typically, your static website will be hosted on https://yourUserName.gitlab.io/ ```javascript -// vue.config.js file to be place in the root of your repository +// vue.config.js file to be placed in the root of your repository module.exports = { publicPath: process.env.NODE_ENV === 'production' @@ -178,6 +178,21 @@ In order to receive direct hits using `history mode` on Vue Router, you need to More information on [Netlify redirects documentation](https://www.netlify.com/docs/redirects/#history-pushstate-and-single-page-apps). +If you are using [@vue/cli-plugin-pwa](https://cli.vuejs.org/core-plugins/pwa.html#vue-cli-plugin-pwa) make sure to exclude the `_redirects` file from being cached by the service worker. +To do so, add the following to your `vue.config.js`: +```javascript +// vue.config.js file to be placed in the root of your repository + +module.exports = { + pwa: { + workboxOptions: { + exclude: [/_redirects/] + } + } +} +``` +Checkout [workboxOptions](https://cli.vuejs.org/core-plugins/pwa.html#configuration) and [exclude](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-webpack-plugin.InjectManifest#InjectManifest) for more. + ### Render [Render](https://render.com) offers [free static site hosting](https://render.com/docs/static-sites) with fully managed SSL, a global CDN and continuous auto deploys from GitHub.