next-pwa Build error with turbo #5199
Unanswered
sideDesert
asked this question in
Help
Replies: 1 comment
-
|
Hey! Just wanted to chime in — you're not doing anything wrong at all. I was building a Next.js 15.3 app inside a turborepo monorepo that was also a PWA. I ran into various issues when trying to build locally and when deploying to Vercel. After some digging, I realized that:
My SolutionOnce I identified that Turbopack was the issue, I moved the app out of the monorepo and set it up as a standalone project with Webpack — and that resolved all the problems. I also managed to get things working with ES Modules. Here's my import type { NextConfig } from "next";
import withPWA from "next-pwa";
import path from "path";
const nextConfig: NextConfig = {
reactStrictMode: true,
devIndicators: false,
webpack: (config) => {
config.resolve.alias["@"] = path.resolve(__dirname);
return config;
},
};
export default withPWA({
dest: "public",
register: true,
skipWaiting: true,
disable: false,
swSrc: "public/sw.js",
})(nextConfig); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I was trying to deploy a PWA with turbo as my monorepo. The PWA works in development but when I try to build it I get this build error
(I have not used any context in the pwa)
Cannot read properties of null (reading useContext)
I tried building the PWA outside the turbo monorepo, and it does work there, I don't really know what I am doing wrong here
My next.config.js
turbo.json
{ "globalEnv": ["NEST_HOST", "HOST_URL", "NODE_ENV"], "$schema": "https://turbo.build/schema.json", "globalDependencies": ["**/.env.*local"], "pipeline": { "build": { "dependsOn": ["^build"], "outputs": [".next/**", "!.next/cache/**", "public/*.js"] }, "lint": {}, "dev": { "cache": false, "persistent": true } } }Beta Was this translation helpful? Give feedback.
All reactions