You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
857 B

import { spawnSync } from 'node:child_process';
import withSerwistInit from '@serwist/next';
// This is optional!
// A revision helps Serwist version a precached page. This
// avoids outdated precached responses being used. Using
// `git rev-parse HEAD` might not the most efficient way
// of determining a revision, however. You may prefer to use
// the hashes of every extra file you precache.
const revision =
spawnSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf-8' }).stdout ??
crypto.randomUUID();
const withSerwist = withSerwistInit({
additionalPrecacheEntries: [{ url: '/~offline', revision }],
// Note: This is only an example. If you use Pages Router,
// use something else that works, such as "service-worker/index.ts".
swSrc: 'app/sw.ts',
swDest: 'public/sw.js',
});
export default withSerwist({
// Your Next.js config
});