Skip to content

Commit a81bc68

Browse files
Merge branch 'main' into mk/redirect-i18n-slash
2 parents c3ccffc + e99f0a0 commit a81bc68

File tree

8 files changed

+2085
-824
lines changed

8 files changed

+2085
-824
lines changed

Diff for: cypress/integration/nx/general.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ describe('Default site', () => {
99
cy.visit('//')
1010
cy.url().should('eq', `${Cypress.config().baseUrl}/`)
1111
})
12-
})
12+
13+
it('serves generated public files', async () => {
14+
cy.request('service-worker.js').then((res) => {
15+
expect(res.status).to.eq(200)
16+
expect(res.headers['content-type']).to.match(/javascript/)
17+
})
18+
})
19+
})

Diff for: demos/nx-next-monorepo-demo/apps/demo-monorepo/next.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// eslint-disable-next-line @typescript-eslint/no-var-requires
22
const withNx = require('@nrwl/next/plugins/with-nx');
3+
const { InjectManifest } = require("workbox-webpack-plugin");
34

45
/**
56
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
@@ -10,6 +11,16 @@ const nextConfig = {
1011
// See: https://github.com/gregberge/svgr
1112
svgr: false,
1213
},
14+
webpack(config, options) {
15+
if (!options.dev) {
16+
const serviceWorkerPlugin = new InjectManifest({
17+
swSrc: "./src/service-worker.ts",
18+
swDest: "../public/service-worker.js",
19+
});
20+
config.plugins.push(serviceWorkerPlugin);
21+
}
22+
return config;
23+
},
1324
};
1425

1526
module.exports = withNx(nextConfig);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference lib="webworker" />
2+
3+
import { PrecacheController } from "workbox-precaching";
4+
5+
declare const self: ServiceWorkerGlobalScope;
6+
7+
console.log(PrecacheController);
8+
console.log(self.__WB_MANIFEST);

0 commit comments

Comments
 (0)