| 50 | { |
| 51 | skipActivation: true, |
| 52 | beforeNavigation(compilation) { |
| 53 | compilation.use((router) => { |
| 54 | router.use('/', (_, res, next) => { |
| 55 | // Appended router are relative to the compilation path. |
| 56 | // Allow the nested worker script to control the root scope. |
| 57 | res.setHeader('Service-Worker-Allowed', '/') |
| 58 | next() |
| 59 | }) |
| 60 | |
| 61 | router.get('/mockServiceWorker-outdated.js', (_, res) => { |
| 62 | return res |
| 63 | .set('content-type', 'application/javascript') |
| 64 | .send(fs.readFileSync(TEMP_SERVICE_WORKER_PATH, 'utf8')) |
| 65 | }) |
| 66 | }) |
| 67 | }, |
| 68 | }, |
| 69 | ) |
| 70 | |