From 65f045eb59d9e82022c90d4a73215566133cb47c Mon Sep 17 00:00:00 2001 From: goodroot <9484709+goodroot@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:43:18 -0800 Subject: [PATCH] Improvements for side-by-side local dev (#80) Easier pattern for running "both apps together". For public, we have a "private" nextJS frontend. :) --- docusaurus.config.js | 22 ++++++++++++++++++++++ package.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 5b8c9084..9088c50f 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -83,6 +83,28 @@ const config = { ], }, ], + function (context, options) { + return { + name: 'development-redirects', + configureWebpack(config, isServer, utils) { + if (process.env.NODE_ENV === 'development') { + return { + devServer: { + onBeforeSetupMiddleware: function (devServer) { + devServer.app.get('*', function (req, res, next) { + // If path doesn't start with /docs, redirect to Next.js + if (!req.path.startsWith('/docs/')) { + return res.redirect(`http://localhost:3000${req.path}`) + } + next() + }) + } + } + } + } + } + } + } ].filter(Boolean), themeConfig: { diff --git a/package.json b/package.json index 008859cf..c8fbbc54 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "license": "Apache-2.0", "scripts": { - "start": "cross-env docusaurus start", + "start": "cross-env docusaurus start --port 3001", "prebuild": "docusaurus clear && node ./scripts/cleanup-guidelines", "build": "cross-env NO_UPDATE_NOTIFIER=true USE_SIMPLE_CSS_MINIFIER=true PWA_SW_CUSTOM= docusaurus build", "deploy": "docusaurus deploy",