Skip to content

Commit

Permalink
revert: remove unnecessary hmr regex
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 7, 2019
1 parent 913897a commit 1ac5f5c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 81 deletions.
4 changes: 2 additions & 2 deletions docs/modules/workbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ Workbox takes a lot of the heavy lifting out of precaching by simplifying the AP

Default is auto generated based on `publicPath`. Supports CDN too.

Default: `/_nuxt/(?!.*(__webpack_hmr|hot-update))`
Default: `/_nuxt/`

### `pagesURLPattern`

(String/Regex) Pattern to match pages to be offlined.

Default is auto generated based on `router.base`.

Default: `/(?!.*(__webpack_hmr|hot-update))`
Default: `/`

<!-- SW -->

Expand Down
6 changes: 2 additions & 4 deletions packages/workbox/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const path = require('path')
const defaults = require('./defaults')
const { joinUrl, getRouteParams, startCase } = require('@nuxtjs/pwa-utils')

const HMRRegex = '(?!.*(__webpack_hmr|hot-update))'

function getOptions (moduleOptions) {
const options = Object.assign({}, defaults, moduleOptions, this.options.workbox)

Expand Down Expand Up @@ -40,7 +38,7 @@ function getOptions (moduleOptions) {

// Cache all _nuxt resources at runtime
if (!options.assetsURLPattern) {
options.assetsURLPattern = joinUrl(options.publicPath, HMRRegex)
options.assetsURLPattern = options.publicPath
}
if (options.cacheAssets) {
options.runtimeCaching.push({
Expand All @@ -51,7 +49,7 @@ function getOptions (moduleOptions) {

// Optionally cache other routes for offline
if (!options.pagesURLPattern) {
options.pagesURLPattern = joinUrl(options.routerBase, HMRRegex)
options.pagesURLPattern = options.routerBase
}
if (options.offline && !options.offlinePage) {
options.runtimeCaching.push({
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/pwa.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ workbox.precaching.precacheAndRoute([
// Register route handlers for runtimeCaching
workbox.routing.registerRoute(new RegExp('https://google.com/.*'), new workbox.strategies.CacheFirst ({}), 'GET')
workbox.routing.registerRoute(new RegExp('/_nuxt/(?!.*(__webpack_hmr|hot-update))'), new workbox.strategies.CacheFirst ({}), 'GET')
workbox.routing.registerRoute(new RegExp('/_nuxt/'), new workbox.strategies.CacheFirst ({}), 'GET')
// Register router handler for offlinePage
workbox.routing.registerRoute(new RegExp('/(?!.*(__webpack_hmr|hot-update))'), ({event}) => {
workbox.routing.registerRoute(new RegExp('/'), ({event}) => {
return new workbox.strategies.NetworkFirst().handle({event})
.catch(() => caches.match('/offline.html'))
})
Expand Down
73 changes: 0 additions & 73 deletions test/hmr.js

This file was deleted.

0 comments on commit 1ac5f5c

Please sign in to comment.