diff --git a/blitz.config.ts b/blitz.config.ts index 72c7145..63697b0 100644 --- a/blitz.config.ts +++ b/blitz.config.ts @@ -1,8 +1,11 @@ -import { BlitzConfig, sessionMiddleware, simpleRolesIsAuthorized } from "blitz"; +/// +import type { BlitzConfig } from "blitz"; +import { sessionMiddleware, simpleRolesIsAuthorized } from "blitz"; +// import withPWA from "next-pwa"; -const withPWA = require("next-pwa"); +type Module = Omit & { exports: BlitzConfig }; -const config: BlitzConfig = { +(module as Module).exports = { middleware: [ sessionMiddleware({ cookiePrefix: "shellphone", @@ -49,15 +52,8 @@ const config: BlitzConfig = { return config }, */ + /*pwa: { + dest: "public", + disable: process.env.NODE_ENV !== "production", + },*/ }; - -module.exports = - process.env.NODE_ENV === "test" - ? config - : withPWA({ - ...config, - pwa: { - dest: "public", - disable: process.env.NODE_ENV !== "production", - }, - }); diff --git a/next-pwa.d.ts b/next-pwa.d.ts new file mode 100644 index 0000000..5e5e466 --- /dev/null +++ b/next-pwa.d.ts @@ -0,0 +1,7 @@ +import type { BlitzConfig } from "blitz"; + +declare module "next-pwa" { + function withPWA(config: BlitzConfig): BlitzConfig; + + export default withPWA; +} diff --git a/test/setup.ts b/test/setup.ts index 07eac19..aa579f9 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -1,3 +1,5 @@ +jest.mock("next-pwa", () => ({ __esModule: true, default: jest.fn().mockImplementation((config) => config) })); + import { setConfig } from "blitz"; // see https://github.com/vercel/next.js/issues/4024