Migrate to a monorepo setup - step 1 * Move web to subfolder /apps/scandic-web * Yarn + transitive deps - Move to yarn - design-system package removed for now since yarn doesn't support the parameter for token (ie project currently broken) - Add missing transitive dependencies as Yarn otherwise prevents these imports - VS Code doesn't pick up TS path aliases unless you open /apps/scandic-web instead of root (will be fixed with monorepo) * Pin framer-motion to temporarily fix typing issue https://github.com/adobe/react-spectrum/issues/7494 * Pin zod to avoid typ error There seems to have been a breaking change in the types returned by zod where error is now returned as undefined instead of missing in the type. We should just handle this but to avoid merge conflicts just pin the dependency for now. * Pin react-intl version Pin version of react-intl to avoid tiny type issue where formatMessage does not accept a generic any more. This will be fixed in a future commit, but to avoid merge conflicts just pin for now. * Pin typescript version Temporarily pin version as newer versions as stricter and results in a type error. Will be fixed in future commit after merge. * Setup workspaces * Add design-system as a monorepo package * Remove unused env var DESIGN_SYSTEM_ACCESS_TOKEN * Fix husky for monorepo setup * Update netlify.toml * Add lint script to root package.json * Add stub readme * Fix react-intl formatMessage types * Test netlify.toml in root * Remove root toml * Update netlify.toml publish path * Remove package-lock.json * Update build for branch/preview builds Approved-by: Linus Flood
301 lines
8.5 KiB
JavaScript
301 lines
8.5 KiB
JavaScript
import * as Sentry from "@sentry/nextjs"
|
|
import createJiti from "jiti"
|
|
import { fileURLToPath } from "url"
|
|
|
|
import { login, logout } from "./constants/routes/handleAuth.js"
|
|
import { myPages } from "./constants/routes/myPages.js"
|
|
|
|
const path = fileURLToPath(new URL(import.meta.url))
|
|
const jiti = createJiti(path)
|
|
jiti("./env/server")
|
|
jiti("./env/client")
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
poweredByHeader: false,
|
|
eslint: { ignoreDuringBuilds: true },
|
|
trailingSlash: false,
|
|
experimental: {
|
|
instrumentationHook: true,
|
|
serverActions: {
|
|
allowedOrigins: [
|
|
"*--web-scandic-hotels.netlify.app",
|
|
"develop--web-scandic-hotels.netlify.app",
|
|
"stage--web-scandic-hotels.netlify.app",
|
|
"test--web-scandic-hotels.netlify.app",
|
|
"master--web-scandic-hotels.netlify.app",
|
|
"*.scandichotels.com",
|
|
],
|
|
},
|
|
},
|
|
images: {
|
|
remotePatterns: [
|
|
{
|
|
protocol: "https",
|
|
hostname: "eu-images.contentstack.com",
|
|
pathname: "/v3/assets/**",
|
|
},
|
|
{
|
|
protocol: "https",
|
|
hostname: "scandichotels.com",
|
|
},
|
|
{
|
|
protocol: "https",
|
|
hostname: "*.scandichotels.com",
|
|
},
|
|
],
|
|
},
|
|
|
|
logging: {
|
|
fetches: {
|
|
fullUrl: true,
|
|
},
|
|
},
|
|
|
|
output: "standalone",
|
|
|
|
webpack: function (config, options) {
|
|
config.module.rules.push(
|
|
{
|
|
test: /\.(graphql|gql)/,
|
|
exclude: /node_modules/,
|
|
loader: "graphql-tag/loader",
|
|
},
|
|
{
|
|
test: /\.svg$/,
|
|
use: ["@svgr/webpack"],
|
|
}
|
|
)
|
|
|
|
return config
|
|
},
|
|
|
|
// https://nextjs.org/docs/app/api-reference/next-config-js/redirects#header-cookie-and-query-matching
|
|
redirects() {
|
|
// Param checks needs to be split as Next.js handles everything
|
|
// in the missing array as AND, therefore they need to be separate
|
|
// to handle when one or more are missing.
|
|
//
|
|
// Docs: all missing items must not match for the redirect to be applied.
|
|
return [
|
|
{
|
|
// ----------------------------------------
|
|
// hotel (hotelId) param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "hotel",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// hotel (hotelId) param has to be an integer
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "hotel",
|
|
type: "query",
|
|
value: "^[0-9]+$",
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// fromdate param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "fromdate",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// fromdate param has to be a date
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "fromdate",
|
|
type: "query",
|
|
value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0?[1-9]|[12]\\d|3[01]))$",
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// todate param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "todate",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// todate param has to be a date
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "todate",
|
|
type: "query",
|
|
value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0?[1-9]|[12]\\d|3[01]))$",
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// room[0].adults param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "room[0].adults",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// room[0].adults param has to be an integer
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "room[0].adults",
|
|
type: "query",
|
|
value: "^[0-9]+$",
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// room[0].ratecode param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "room[0].ratecode",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
{
|
|
// ----------------------------------------
|
|
// room[0].roomtype param missing
|
|
// ----------------------------------------
|
|
source: "/:lang/hotelreservation/details",
|
|
destination: "/:lang/hotelreservation/select-rate",
|
|
missing: [
|
|
{
|
|
key: "room[0].roomtype",
|
|
type: "query",
|
|
value: undefined,
|
|
},
|
|
],
|
|
permanent: false,
|
|
},
|
|
]
|
|
},
|
|
|
|
rewrites() {
|
|
return {
|
|
beforeFiles: [
|
|
{ source: login.da, destination: "/da/login" },
|
|
{ source: login.de, destination: "/de/login" },
|
|
{ source: login.fi, destination: "/fi/login" },
|
|
{ source: login.no, destination: "/no/login" },
|
|
{ source: login.sv, destination: "/sv/login" },
|
|
{ source: logout.da, destination: "/da/logout" },
|
|
{ source: logout.de, destination: "/de/logout" },
|
|
{ source: logout.fi, destination: "/fi/logout" },
|
|
{ source: logout.no, destination: "/no/logout" },
|
|
{ source: logout.sv, destination: "/sv/logout" },
|
|
{
|
|
source: `${myPages.en}/:path*`,
|
|
destination: `/en/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: `${myPages.da}/:path*`,
|
|
destination: `/da/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: `${myPages.de}/:path*`,
|
|
destination: `/de/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: `${myPages.fi}/:path*`,
|
|
destination: `/fi/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: `${myPages.no}/:path*`,
|
|
destination: `/no/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: `${myPages.sv}/:path*`,
|
|
destination: `/sv/my-pages/:path*`,
|
|
},
|
|
{
|
|
source: "/:lang/hotelreservation/payment-callback/:status",
|
|
destination:
|
|
"/:lang/hotelreservation/payment-callback?status=:status",
|
|
},
|
|
],
|
|
}
|
|
},
|
|
}
|
|
|
|
export default Sentry.withSentryConfig(nextConfig, {
|
|
org: "scandic-hotels",
|
|
project: "scandic-web",
|
|
enabled: process.env.NODE_ENV !== "development",
|
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
|
|
// Only print logs for uploading source maps in CI
|
|
silent: !process.env.CI,
|
|
|
|
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
widenClientFileUpload: true,
|
|
|
|
// Automatically annotate React components to show their full name in breadcrumbs and session replay
|
|
reactComponentAnnotation: {
|
|
enabled: true,
|
|
},
|
|
|
|
hideSourceMaps: true,
|
|
disableLogger: true,
|
|
})
|