Skip to content

Commit

Permalink
Fix /_next/../public/ prefix on sw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowwalker committed Apr 17, 2022
1 parent a8f471f commit 363ed3e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Examples

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
strategy:
matrix:
example:
[
minimal,
next-9,
lifecycle,
cookie,
cache-on-front-end-nav,
custom-worker,
customer-ts-worker,
next-image,
offline-fallback,
offline-fallback-v2,
web-push
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm link
- run: npm install && npm link next-pwa && npm build
working-directory: examples/${{ matrix.example }}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGELOG

**NOTE: for newer changelog, go to [release page](https://github.com/shadowwalker/next-pwa/releases) instead.**

## 5.5.0

### Fix
Expand Down
2 changes: 1 addition & 1 deletion examples/offline-fallback-v2/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = withPWA({
pwa: {
dest: 'public',
fallbacks: {
image: '/static/images/fallback.png',
image: '/static/images/fallback.png'
// document: '/other-offline', // if you want to fallback to a custom page other than /_offline
// font: '/static/font/fallback.woff2',
// audio: ...,
Expand Down
1 change: 1 addition & 0 deletions examples/offline-fallback-v2/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default () => (
<title>next-pwa example</title>
</Head>
<h1>Next.js + PWA = AWESOME!</h1>
<h2>Routes not cached will fallback to /_offline page</h2>
<h2>Following image will fallback to placeholder when offline</h2>
<img src='https://source.unsplash.com/600x400/?cat' />
</>
Expand Down
1 change: 1 addition & 0 deletions examples/offline-fallback/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default () => (
<title>next-pwa example</title>
</Head>
<h1>Next.js + PWA = AWESOME!</h1>
<h2>Routes not cached will fallback to /_offline page</h2>
<h2>Following image will fallback to placeholder when offline</h2>
<img src='https://source.unsplash.com/600x400/?cat' />
</>
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = (nextConfig = {}) => ({
importScripts = [],
publicExcludes = ['!noprecache/**/*'],
buildExcludes = [],
modifyURLPrefix = {},
manifestTransforms = [],
fallbacks = {},
cacheOnFrontEndNav = false,
Expand Down Expand Up @@ -219,6 +220,10 @@ module.exports = (nextConfig = {}) => ({
return false
}
],
modifyURLPrefix: {
...modifyURLPrefix,
'/_next/../public/': '/'
},
manifestTransforms: [
...manifestTransforms,
async (manifestEntries, compilation) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-pwa",
"version": "5.5.0",
"version": "5.5.1",
"description": "Next.js with PWA, powered by workbox.",
"main": "index.js",
"repository": "https://github.com/shadowwalker/next-pwa",
Expand Down

0 comments on commit 363ed3e

Please sign in to comment.