Nuxt.jsとNext.jsの静的アセット、Next.jsにおけるService Worker導入
Nuxt.jsの場合
https://ja.nuxtjs.org/guide/assets/#static
Next.jsの場合
https://nextjs-docs-ja.netlify.com/docs/#静的ファイル-例-画像-のサーブ
PWA対応時の課題
Nextの場合、service-workerを仮に/staticに置いたとして、/static/sw.jsみたいなURLになる。
scopeを/としたい場合にうまくいかない
service workerは自分がいる場所(URL上)より下位のページしかコントロールできない
したがって、/sw.jsみたいなURLでアクセスできる必要がある
https://medium.com/@anatomic/using-a-service-worker-with-next-js-460e0168a60a
Ideally, the service worker to be registered would be loaded from the root scope (i.e. https://my.app.com/sw.js) which, in Next.js apps, requires a custom server implementation.
#Next.js #Nuxt.js