mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add pwa in nextjs
This commit is contained in:
@@ -10,7 +10,9 @@ import type { ProjectConfig } from "../types";
|
||||
export async function setupAddons(config: ProjectConfig) {
|
||||
const { addons, frontend, projectDir } = config;
|
||||
const hasReactWebFrontend =
|
||||
frontend.includes("react-router") || frontend.includes("tanstack-router");
|
||||
frontend.includes("react-router") ||
|
||||
frontend.includes("tanstack-router") ||
|
||||
frontend.includes("next");
|
||||
const hasNuxtFrontend = frontend.includes("nuxt");
|
||||
const hasSvelteFrontend = frontend.includes("svelte");
|
||||
const hasSolidFrontend = frontend.includes("solid");
|
||||
|
||||
@@ -557,10 +557,20 @@ export async function setupAddonsTemplate(
|
||||
let addonDestDir = projectDir;
|
||||
|
||||
if (addon === "pwa") {
|
||||
addonSrcDir = path.join(PKG_ROOT, "templates/addons/pwa/apps/web");
|
||||
addonDestDir = path.join(projectDir, "apps/web");
|
||||
|
||||
if (!(await fs.pathExists(addonDestDir))) {
|
||||
const webAppDir = path.join(projectDir, "apps/web");
|
||||
if (!(await fs.pathExists(webAppDir))) {
|
||||
continue;
|
||||
}
|
||||
addonDestDir = webAppDir;
|
||||
if (context.frontend.includes("next")) {
|
||||
addonSrcDir = path.join(PKG_ROOT, "templates/addons/pwa/apps/web/next");
|
||||
} else if (
|
||||
context.frontend.some((f) =>
|
||||
["tanstack-router", "react-router", "solid"].includes(f),
|
||||
)
|
||||
) {
|
||||
addonSrcDir = path.join(PKG_ROOT, "templates/addons/pwa/apps/web/vite");
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,7 +800,10 @@ function processAndValidateFlags(
|
||||
);
|
||||
const hasCompatibleWebFrontend = effectiveFrontend?.some((f) => {
|
||||
const isPwaCompatible =
|
||||
f === "tanstack-router" || f === "react-router" || f === "solid";
|
||||
f === "tanstack-router" ||
|
||||
f === "react-router" ||
|
||||
f === "solid" ||
|
||||
f === "next";
|
||||
const isTauriCompatible =
|
||||
f === "tanstack-router" ||
|
||||
f === "react-router" ||
|
||||
@@ -828,7 +831,7 @@ function processAndValidateFlags(
|
||||
let incompatibleReason = "Selected frontend is not compatible.";
|
||||
if (config.addons.includes("pwa")) {
|
||||
incompatibleReason =
|
||||
"PWA requires tanstack-router, react-router, or solid.";
|
||||
"PWA requires tanstack-router, react-router, next, or solid.";
|
||||
}
|
||||
if (config.addons.includes("tauri")) {
|
||||
incompatibleReason =
|
||||
|
||||
@@ -18,7 +18,8 @@ export async function getAddonsChoice(
|
||||
const hasCompatiblePwaFrontend =
|
||||
frontends?.includes("react-router") ||
|
||||
frontends?.includes("tanstack-router") ||
|
||||
frontends?.includes("solid");
|
||||
frontends?.includes("solid") ||
|
||||
frontends?.includes("next");
|
||||
|
||||
const hasCompatibleTauriFrontend =
|
||||
frontends?.includes("react-router") ||
|
||||
|
||||
Reference in New Issue
Block a user