From 611400c3d6f3f413a5fe038bdbab0d988b8eaf3e Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Tue, 24 Mar 2026 12:47:23 -0700 Subject: [PATCH] fix: move maplibre-gl CSS to layout to fix Next.js webpack build The maplibre-gl webpack alias in next.config.mjs was intercepting CSS sub-path imports, causing 'Module not found' for maplibre-gl/dist/maplibre-gl.css. Removed the alias entirely (not needed for Next.js 14) and moved the CSS import to layout.tsx so it resolves directly from node_modules. Also adds the prisma migration file for RouteSegment table (20260324000000_add_route_segments). Co-Authored-By: Claude Opus 4.6 --- next.config.mjs | 9 ------ .../migration.sql | 29 +++++++++++++++++++ src/app/layout.tsx | 1 + src/components/trips/TripMap.tsx | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 prisma/migrations/20260324000000_add_route_segments/migration.sql diff --git a/next.config.mjs b/next.config.mjs index d96cef7..b044d19 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,16 +1,7 @@ -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - /** @type {import('next').NextConfig} */ const nextConfig = { output: 'standalone', basePath: '/rtrips', - webpack: (config) => { - config.resolve.alias['maplibre-gl'] = path.resolve(__dirname, 'node_modules/maplibre-gl/dist/maplibre-gl.js'); - return config; - }, }; export default nextConfig; diff --git a/prisma/migrations/20260324000000_add_route_segments/migration.sql b/prisma/migrations/20260324000000_add_route_segments/migration.sql new file mode 100644 index 0000000..a2c34e2 --- /dev/null +++ b/prisma/migrations/20260324000000_add_route_segments/migration.sql @@ -0,0 +1,29 @@ +-- CreateTable +CREATE TABLE "RouteSegment" ( + "id" TEXT NOT NULL, + "tripId" TEXT NOT NULL, + "fromDestId" TEXT NOT NULL, + "toDestId" TEXT NOT NULL, + "profile" TEXT NOT NULL DEFAULT 'driving-car', + "distanceMeters" INTEGER, + "durationSeconds" INTEGER, + "geometry" TEXT, + "computedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "RouteSegment_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "RouteSegment_tripId_fromDestId_toDestId_profile_key" ON "RouteSegment"("tripId", "fromDestId", "toDestId", "profile"); + +-- CreateIndex +CREATE INDEX "RouteSegment_tripId_idx" ON "RouteSegment"("tripId"); + +-- AddForeignKey +ALTER TABLE "RouteSegment" ADD CONSTRAINT "RouteSegment_tripId_fkey" FOREIGN KEY ("tripId") REFERENCES "Trip"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RouteSegment" ADD CONSTRAINT "RouteSegment_fromDestId_fkey" FOREIGN KEY ("fromDestId") REFERENCES "Destination"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RouteSegment" ADD CONSTRAINT "RouteSegment_toDestId_fkey" FOREIGN KEY ("toDestId") REFERENCES "Destination"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 1983e62..9c8b125 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,6 @@ import type { Metadata } from 'next' import { Inter } from 'next/font/google' +import 'maplibre-gl/dist/maplibre-gl.css' import './globals.css' import { AuthProvider } from '@/components/AuthProvider' import { Header } from '@/components/Header' diff --git a/src/components/trips/TripMap.tsx b/src/components/trips/TripMap.tsx index 70a19f2..e1ff1f3 100644 --- a/src/components/trips/TripMap.tsx +++ b/src/components/trips/TripMap.tsx @@ -2,7 +2,7 @@ import { useRef, useCallback, useMemo } from 'react'; import Map, { Marker, Source, Layer, NavigationControl } from 'react-map-gl/maplibre'; -import 'maplibre-gl/dist/maplibre-gl.css'; +// maplibre-gl CSS is imported globally in layout.tsx interface Destination { id: string;