@geosynk/vertigis-web-sdk 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +72 -9
  2. package/package.json +6 -6
  3. package/scripts/create.js +12 -2
  4. package/template/app/favicon.ico +20 -0
  5. package/template/app/favicon.svg +20 -0
  6. package/template/package.json +1 -1
  7. package/template-custom/AGENTS.md +86 -33
  8. package/template-custom/Dockerfile.build +46 -0
  9. package/template-custom/app/favicon.ico +20 -0
  10. package/template-custom/app/favicon.svg +20 -0
  11. package/template-custom/build.bat +84 -5
  12. package/template-custom/build.sh +82 -2
  13. package/template-custom/certs/generate-cert.bat +10 -9
  14. package/template-custom/certs/generate-cert.sh +1 -0
  15. package/template-custom/project.config +107 -0
  16. package/template-custom/scripts/configure-portal.js +56 -7
  17. package/template-custom/scripts/load-config.bat +12 -0
  18. package/template-custom/scripts/load-config.sh +26 -0
  19. package/template-custom/scripts/remote-sync.bat +12 -0
  20. package/template-custom/scripts/remote-sync.sh +42 -0
  21. package/template-custom/scripts/verify_zero_cosmetic_sx.py +419 -0
  22. package/template-custom/src/auth/index.ts +18 -1
  23. package/template-custom/src/components/CustomWidget/CustomWidget.css +1 -0
  24. package/template-custom/src/components/CustomWidget/CustomWidget.tsx +28 -49
  25. package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.css +0 -0
  26. package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +12 -19
  27. package/template-custom/src/index.ts +4 -1
  28. package/template-custom/src/tokens/VertiGisThemeProvider.tsx +14 -0
  29. package/template-custom/src/tokens/index.ts +3 -0
  30. package/template-custom/src/tokens/muiTheme.ts +61 -0
  31. package/template-custom/src/tokens/spacing.ts +24 -0
  32. package/template-custom/src/tokens/typography.ts +0 -4
  33. package/template-custom/src/tokens/ui.ts +58 -3
  34. package/template-custom/start.bat +24 -1
  35. package/template-custom/start.sh +35 -0
  36. package/template-custom/webpack.config.js +46 -146
@@ -0,0 +1,61 @@
1
+ import { createTheme, type Theme } from "@mui/material/styles";
2
+
3
+ import { UI_TOKENS } from "./ui";
4
+
5
+ /**
6
+ * The only home for cosmetic styling. Components keep sx to layout, geometry and 8px-grid spacing,
7
+ * inherit everything else from the host shell's CSS custom properties, and express state as
8
+ * data attributes (e.g. <Card data-status={status}>) that are styled here.
9
+ */
10
+ export function createVertiGisTheme(isDark: boolean): Theme {
11
+ return createTheme({
12
+ palette: { mode: isDark ? "dark" : "light" },
13
+ typography: { fontFamily: "inherit" },
14
+ components: {
15
+ MuiCard: {
16
+ defaultProps: { variant: "outlined" },
17
+ styleOverrides: {
18
+ root: {
19
+ position: "relative",
20
+ borderRadius: UI_TOKENS.shape.borderRadiusLarge,
21
+ backgroundColor: UI_TOKENS.surface.primary,
22
+ border: `1px solid ${UI_TOKENS.border.primary}`,
23
+ boxShadow: "none",
24
+ '&.StatusCard-root[data-status="Open"], &.StatusCard-root[data-status="Opened"]': {
25
+ borderLeftWidth: 4,
26
+ borderLeftColor: UI_TOKENS.status.warningFg,
27
+ },
28
+ '&.StatusCard-root[data-status="In Progress"]': {
29
+ borderLeftWidth: 4,
30
+ borderLeftColor: UI_TOKENS.accent.primary,
31
+ },
32
+ '&.StatusCard-root[data-status="Completed"]': {
33
+ borderLeftWidth: 4,
34
+ borderLeftColor: UI_TOKENS.status.successFg,
35
+ },
36
+ '&.StatusCard-root[data-status="Closed"], &.StatusCard-root[data-status="Archived"]': {
37
+ borderLeftWidth: 4,
38
+ borderLeftColor: UI_TOKENS.text.secondary,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ MuiPaper: {
44
+ styleOverrides: {
45
+ root: { backgroundImage: "none" },
46
+ outlined: { borderColor: UI_TOKENS.border.primary, borderRadius: UI_TOKENS.shape.borderRadius },
47
+ },
48
+ },
49
+ MuiFormControlLabel: {
50
+ styleOverrides: {
51
+ root: {
52
+ marginLeft: 0,
53
+ marginRight: 0,
54
+ },
55
+ },
56
+ },
57
+ },
58
+ });
59
+ }
60
+
61
+ export default createVertiGisTheme;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Standardized Spacing Scale & Semantic Roles (MUI 8px Grid Multipliers)
3
+ */
4
+ export const SPACING = {
5
+ // Base Scale (Multipliers: 1 = 8px)
6
+ none: 0,
7
+ xs: 0.5, // 4px - micro gaps (badges, inline icons)
8
+ sm: 1, // 8px - compact elements (form controls, list items)
9
+ md: 1.5, // 12px - intermediate (filter inputs, compact cards)
10
+ lg: 2, // 16px - standard sections (card body, dialogs)
11
+ xl: 3, // 24px - major layout gutters
12
+ xxl: 4, // 32px - page headers, empty states
13
+
14
+ // Semantic Roles (Intent-Driven)
15
+ inlineGap: 0.5, // Gap between icon and accompanying text
16
+ controlGap: 1, // Gap between checkboxes, switches, and radio items
17
+ fieldGap: 1.5, // Gap between form fields / dropdowns
18
+ sectionGap: 2, // Gap between major card or panel sections
19
+ cardPadding: 1.5, // Standard inner padding for cards
20
+ panelPadding: 2, // Standard inner padding for drawers/panels
21
+ } as const;
22
+
23
+ export type SpacingToken = typeof SPACING[keyof typeof SPACING];
24
+ export default SPACING;
@@ -3,10 +3,6 @@
3
3
  */
4
4
 
5
5
  export const TYPOGRAPHY_TOKENS = {
6
- fontFamily: {
7
- primary: "var(--defaultFont, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)",
8
- mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
9
- },
10
6
  fontSize: {
11
7
  h5: "1.5rem",
12
8
  h6: "1.25rem",
@@ -1,9 +1,55 @@
1
1
  /**
2
2
  * UI Design Tokens for VertiGIS Studio Web SDK
3
- * Maps official VertiGIS CSS custom properties with safe WCAG AA fallbacks.
3
+ * Direct 1:1 mapping of official VertiGIS host CSS variables with guaranteed WCAG AA fallbacks.
4
4
  */
5
5
 
6
6
  export const UI_TOKENS = {
7
+ // 1. Direct 1:1 Host CSS Custom Property Mapping (Exact Names & Guaranteed Fallbacks)
8
+ primaryBackground: "var(--primaryBackground, #ffffff)",
9
+ secondaryBackground: "var(--secondaryBackground, #f5f5f5)",
10
+ overlayBackground: "var(--overlayBackground, rgba(0, 0, 0, 0.5))",
11
+
12
+ primaryForeground: "var(--primaryForeground, #212121)",
13
+ secondaryForeground: "var(--secondaryForeground, #666666)",
14
+ disabledForeground: "var(--disabledForeground, #9e9e9e)",
15
+
16
+ primaryBorder: "var(--primaryBorder, #e0e0e0)",
17
+ secondaryBorder: "var(--secondaryBorder, #eeeeee)",
18
+ focusBorder: "var(--focusBorder, #007ac2)",
19
+
20
+ primaryAccent: "var(--primaryAccent, #007ac2)",
21
+ primaryAccentHover: "var(--primaryAccentHover, #005a91)",
22
+ primaryAccentLight: "var(--primaryAccentLight, #e1f5fe)",
23
+ buttonForeground: "var(--buttonForeground, #ffffff)",
24
+ emphasizedButtonBackground: "var(--emphasizedButtonBackground, var(--primaryAccent, #007ac2))",
25
+ emphasizedButtonForeground: "var(--emphasizedButtonForeground, #ffffff)",
26
+
27
+ itemHoverBackground: "var(--itemHoverBackground, rgba(0, 0, 0, 0.04))",
28
+ itemSelectedBackground: "var(--itemSelectedBackground, rgba(0, 122, 194, 0.12))",
29
+
30
+ alertRedBackground: "var(--alertRedBackground, #fdecea)",
31
+ alertRedForeground: "var(--alertRedForeground, #d32f2f)",
32
+ alertRedBorder: "var(--alertRedBorder, #f5c2c7)",
33
+
34
+ alertGreenBackground: "var(--alertGreenBackground, #edf7ed)",
35
+ alertGreenForeground: "var(--alertGreenForeground, #2e7d32)",
36
+ alertGreenBorder: "var(--alertGreenBorder, #c3e6cb)",
37
+
38
+ alertAmberBackground: "var(--alertAmberBackground, #fff4e5)",
39
+ alertAmberForeground: "var(--alertAmberForeground, #ed6c02)",
40
+ alertAmberBorder: "var(--alertAmberBorder, #ffeeba)",
41
+
42
+ alertGrayBackground: "var(--alertGrayBackground, #e8f4fd)",
43
+ alertGrayForeground: "var(--alertGrayForeground, #0288d1)",
44
+ alertGrayBorder: "var(--alertGrayBorder, #bee5eb)",
45
+
46
+ borderRadius: "var(--borderRadius, 4px)",
47
+ borderRadiusSm: "var(--borderRadiusSm, 2px)",
48
+ borderRadiusLarge: "var(--borderRadiusLarge, 8px)",
49
+ shadowPrimary: "var(--shadowPrimary, 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24))",
50
+ shadowElevated: "var(--shadowElevated, 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23))",
51
+
52
+ // 2. Semantic Groupings
7
53
  surface: {
8
54
  primary: "var(--primaryBackground, #ffffff)",
9
55
  secondary: "var(--secondaryBackground, #f5f5f5)",
@@ -21,15 +67,22 @@ export const UI_TOKENS = {
21
67
  secondary: "var(--secondaryBorder, #eeeeee)",
22
68
  focus: "var(--focusBorder, #007ac2)",
23
69
  },
70
+ // Use accent tokens for borders, icons, indicators and text on panel surfaces.
71
+ // Do not use accent.primary as a background for text: the host has no foreground token that is
72
+ // paired with --primaryAccent. In brand themes, --primaryAccent and the button foregrounds can be
73
+ // the same colour (for example black on black).
24
74
  accent: {
25
75
  primary: "var(--primaryAccent, #007ac2)",
26
76
  hover: "var(--primaryAccentHover, #005a91)",
27
77
  light: "var(--primaryAccentLight, #e1f5fe)",
28
- contrastText: "var(--buttonForeground, #ffffff)",
29
78
  },
79
+ // Each background is used with the foreground of the same pair:
80
+ // buttonBackground + buttonForeground (emphasized button pair from the host theme).
81
+ // Selected state (toggle, list item): itemSelected background, inherited text
82
+ // (text.primary only in createTheme styleOverrides), accent.primary border.
30
83
  control: {
31
84
  buttonBackground: "var(--emphasizedButtonBackground, var(--primaryAccent, #007ac2))",
32
- buttonForeground: "var(--buttonForeground, #ffffff)",
85
+ buttonForeground: "var(--emphasizedButtonForeground, #ffffff)",
33
86
  itemHover: "var(--itemHoverBackground, rgba(0, 0, 0, 0.04))",
34
87
  itemSelected: "var(--itemSelectedBackground, rgba(0, 122, 194, 0.12))",
35
88
  },
@@ -50,7 +103,9 @@ export const UI_TOKENS = {
50
103
  shape: {
51
104
  borderRadius: "var(--borderRadius, 4px)",
52
105
  borderRadiusSm: "var(--borderRadiusSm, 2px)",
106
+ borderRadiusLarge: "var(--borderRadiusLarge, 8px)",
53
107
  borderRadiusLg: "var(--borderRadiusLg, 8px)",
108
+ borderRadiusRound: "50%",
54
109
  borderRadiusPill: "9999px",
55
110
  shadowPrimary: "var(--shadowPrimary, 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24))",
56
111
  shadowElevated: "var(--shadowElevated, 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23))",
@@ -1,5 +1,18 @@
1
1
  @echo off
2
2
  setlocal enabledelayedexpansion
3
+ rem Usage: start.bat normal dev server
4
+ rem start.bat remote pull first, then re-check the remote while the server runs
5
+ rem start.bat remote <branch>
6
+ rem
7
+ rem Values that you do not give on the command line come from project.config:
8
+ rem REMOTE_SYNC, REMOTE_BRANCH, REMOTE_INTERVAL. See project.config for the description of each value.
9
+ cd /d "%~dp0"
10
+ call scripts\load-config.bat
11
+ set "REMOTE_MODE="
12
+ if /i "%~1"=="remote" set "REMOTE_MODE=1"
13
+ if /i "!CFG_REMOTE_SYNC!"=="true" set "REMOTE_MODE=1"
14
+ set "SYNC_INTERVAL=!CFG_REMOTE_INTERVAL!"
15
+ if "!SYNC_INTERVAL!"=="" set "SYNC_INTERVAL=5"
3
16
  echo ========================================================
4
17
  echo VertiGIS Studio Web SDK Development Server
5
18
  echo Serving: https://localtest.me:3001 & https://localhost:3000
@@ -13,5 +26,15 @@ for %%P in (3001 3000) do (
13
26
  if exist "certs\generate-cert.bat" (
14
27
  call "certs\generate-cert.bat"
15
28
  )
29
+ if defined REMOTE_MODE (
30
+ set "SYNC_BRANCH="
31
+ if /i "%~1"=="remote" set "SYNC_BRANCH=%~2"
32
+ if "!SYNC_BRANCH!"=="" set "SYNC_BRANCH=!CFG_REMOTE_BRANCH!"
33
+ if "!SYNC_BRANCH!"=="" for /f %%b in ('git rev-parse --abbrev-ref HEAD') do set SYNC_BRANCH=%%b
34
+ echo Remote mode: pulling origin/!SYNC_BRANCH! and re-checking every !SYNC_INTERVAL!s...
35
+ git pull --ff-only origin !SYNC_BRANCH!
36
+ start "git-sync" /min cmd /c "scripts\remote-sync.bat !SYNC_BRANCH! !SYNC_INTERVAL!"
37
+ )
16
38
  echo Starting development server (npm start)...
17
- npm start
39
+ call npm start
40
+ if defined REMOTE_MODE taskkill /FI "WINDOWTITLE eq git-sync*" /F >nul 2>&1
@@ -1,6 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
+ # Usage: ./start.sh normal dev server
5
+ # ./start.sh remote pull first, then re-check the remote every 5s while the server runs
6
+ # ./start.sh remote <branch> [seconds]
7
+ #
8
+ # Values that you do not give on the command line come from project.config:
9
+ # REMOTE_SYNC, REMOTE_BRANCH, REMOTE_INTERVAL. See project.config for the description of each value.
10
+ cd "$(dirname "${BASH_SOURCE[0]}")"
11
+ # shellcheck source=scripts/load-config.sh
12
+ source ./scripts/load-config.sh
13
+
14
+ REMOTE_MODE=""
15
+ if [ "${1:-}" = "remote" ] || [ "${CFG_REMOTE_SYNC:-false}" = "true" ]; then
16
+ REMOTE_MODE=1
17
+ [ "${1:-}" = "remote" ] && shift
18
+ SYNC_BRANCH="${1:-${CFG_REMOTE_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}}"
19
+ SYNC_INTERVAL="${2:-${CFG_REMOTE_INTERVAL:-5}}"
20
+ fi
21
+
4
22
  echo "========================================================"
5
23
  echo " VertiGIS Studio Web SDK Development Server"
6
24
  echo " Serving: https://localtest.me:3001 & https://localhost:3000"
@@ -19,5 +37,22 @@ if [ -f "./certs/generate-cert.sh" ]; then
19
37
  bash ./certs/generate-cert.sh
20
38
  fi
21
39
 
40
+ # Check Linux inotify limits to prevent EMFILE watcher crashes with chokidar
41
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
42
+ CURR_INSTANCES=$(sysctl -n fs.inotify.max_user_instances 2>/dev/null || echo 1024)
43
+ if [ "$CURR_INSTANCES" -lt 512 ]; then
44
+ echo "[WARN] fs.inotify.max_user_instances is low ($CURR_INSTANCES). You may encounter EMFILE errors."
45
+ echo " Recommended fix: sudo sysctl -w fs.inotify.max_user_instances=8192 fs.inotify.max_user_watches=524288"
46
+ fi
47
+ fi
48
+
49
+ if [ -n "$REMOTE_MODE" ]; then
50
+ echo "Remote mode: syncing with origin/$SYNC_BRANCH every ${SYNC_INTERVAL}s..."
51
+ bash ./scripts/remote-sync.sh "$SYNC_BRANCH" "$SYNC_INTERVAL" --once
52
+ bash ./scripts/remote-sync.sh "$SYNC_BRANCH" "$SYNC_INTERVAL" &
53
+ SYNC_PID=$!
54
+ trap 'kill $SYNC_PID 2>/dev/null || true' EXIT INT TERM
55
+ fi
56
+
22
57
  echo "Starting development server (npm start)..."
23
58
  npm start
@@ -1,6 +1,5 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import https from "node:https";
4
3
 
5
4
  let defaultWebpackConfig, merge;
6
5
  try {
@@ -13,154 +12,55 @@ try {
13
12
  merge = mod.merge;
14
13
  }
15
14
 
15
+ const isProduction = process.env.NODE_ENV === "production";
16
16
 
17
- /**
18
- * Starts a lightweight zero-dependency dual-port forwarder on port 3000 forwarding to port 3001.
19
- * This makes the extension simultaneously reachable at both https://localtest.me:3001 and
20
- * https://localhost:3000 (preventing CORS / port mismatch issues in ArcGIS Enterprise/Portal).
21
- */
22
- let bridgeStarted = false;
23
- function setupDualPortBridge(targetPort = 3001, bridgePort = 3000) {
24
- if (bridgeStarted) return;
25
- bridgeStarted = true;
26
-
27
- try {
28
- const certPath = path.resolve(process.cwd(), "certs/cert.pem");
29
- const keyPath = path.resolve(process.cwd(), "certs/key.pem");
30
- if (!fs.existsSync(certPath) || !fs.existsSync(keyPath)) return;
31
-
32
- const options = {
33
- cert: fs.readFileSync(certPath),
34
- key: fs.readFileSync(keyPath),
35
- };
36
-
37
- const server = https.createServer(options, (req, res) => {
38
- const clientReq = https.request(
39
- {
40
- hostname: "127.0.0.1",
41
- port: targetPort,
42
- path: req.url,
43
- method: req.method,
44
- headers: { ...req.headers, host: `localhost:${targetPort}` },
45
- rejectUnauthorized: false,
46
- },
47
- clientRes => {
48
- res.writeHead(clientRes.statusCode || 200, {
49
- ...clientRes.headers,
50
- "Access-Control-Allow-Origin": "*",
51
- "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
52
- "Access-Control-Allow-Headers": "*",
53
- "Access-Control-Allow-Private-Network": "true",
54
- });
55
- clientRes.pipe(res);
56
- }
57
- );
58
-
59
- clientReq.on("error", () => {
60
- res.writeHead(502);
61
- res.end("Bridge connection error");
62
- });
63
-
64
- req.pipe(clientReq);
65
- });
66
-
67
- server.on("upgrade", (req, socket) => {
68
- const clientReq = https.request({
69
- hostname: "127.0.0.1",
70
- port: targetPort,
71
- path: req.url,
72
- method: req.method,
73
- headers: req.headers,
74
- rejectUnauthorized: false,
75
- });
76
-
77
- clientReq.on("upgrade", (clientRes, clientSocket) => {
78
- socket.write(
79
- "HTTP/1.1 101 Switching Protocols\r\n" +
80
- Object.entries(clientRes.headers)
81
- .map(([k, v]) => `${k}: ${v}`)
82
- .join("\r\n") +
83
- "\r\n\r\n"
84
- );
85
- clientSocket.pipe(socket).pipe(clientSocket);
86
- });
87
-
88
- clientReq.on("error", () => socket.destroy());
89
- clientReq.end();
90
- });
91
-
92
- server.listen(bridgePort, "0.0.0.0", () => {
93
- console.log(
94
- `<i> [dual-port-bridge] Also available at https://localhost:${bridgePort} & https://localtest.me:${bridgePort}`
95
- );
96
- });
97
-
98
- server.on("error", err => {
99
- console.log(
100
- `<i> [dual-port-bridge] Port ${bridgePort} unavailable (${err.message}). Serving exclusively on :${targetPort}`
101
- );
102
- });
103
- } catch {
104
- // Silently skip if port forwarder cannot be initialized
105
- }
106
- }
107
-
108
- const typeIndex = process.argv.indexOf("--type");
109
- const isHttp = typeIndex !== -1 && process.argv[typeIndex + 1] === "http";
17
+ // Use the certificate from certs/ (made by certs/generate-cert.sh or .bat). It covers localtest.me and localhost.
18
+ // Without it, webpack-dev-server makes its own certificate, and that certificate does not cover localtest.me.
19
+ const certDir = path.join(import.meta.dirname, "certs");
20
+ const keyFile = path.join(certDir, "key.pem");
21
+ const certFile = path.join(certDir, "cert.pem");
22
+ const hasCert = fs.existsSync(keyFile) && fs.existsSync(certFile);
110
23
 
111
24
  export default merge(defaultWebpackConfig, {
112
- devServer: {
113
- allowedHosts: "all",
114
- host: "0.0.0.0",
115
- port: 3001,
116
- server: isHttp ? "http" : "https",
117
- open: isHttp ? "http://localhost:3001/" : "https://localtest.me:3001/",
118
- headers: {
119
- "Access-Control-Allow-Origin": "*",
120
- "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
121
- "Access-Control-Allow-Headers": "*",
122
- "Access-Control-Allow-Private-Network": "true",
123
- },
124
- client: {
125
- webSocketURL: {
126
- hostname: isHttp ? "localhost" : "localtest.me",
127
- pathname: "/ws",
128
- port: 3001,
129
- protocol: isHttp ? "ws" : "wss",
130
- },
131
- },
132
- setupMiddlewares: (middlewares, devServer) => {
133
- middlewares.unshift({
134
- name: "portal-auth-interceptor",
135
- middleware: (req, res, next) => {
136
- const url = req.url.split("?")[0];
137
- if (url === "/viewer/auth/portal.json" || url === "/auth/portal.json") {
138
- const portalJsonPath = path.resolve(process.cwd(), "app/auth/portal.json");
139
- if (fs.existsSync(portalJsonPath)) {
140
- res.setHeader("Content-Type", "application/json");
141
- res.setHeader("Access-Control-Allow-Origin", "*");
142
- res.end(fs.readFileSync(portalJsonPath, "utf-8"));
143
- return;
144
- }
145
- }
146
- if (url === "/oauth_callback.html" || url === "/viewer/oauth_callback.html") {
147
- const cbPath = path.resolve(process.cwd(), "app/oauth_callback.html");
148
- if (fs.existsSync(cbPath)) {
149
- res.setHeader("Content-Type", "text/html");
150
- res.setHeader("Access-Control-Allow-Origin", "*");
151
- res.end(fs.readFileSync(cbPath, "utf-8"));
152
- return;
153
- }
154
- }
155
- next();
156
- },
157
- });
158
- return middlewares;
159
- },
160
- onListening: function () {
161
- if (!isHttp) {
162
- setupDualPortBridge(3001, 3000);
163
- }
25
+ // 1. Filesystem caching to dramatically speed up rebuild times
26
+ cache: {
27
+ type: "filesystem",
28
+ buildDependencies: {
29
+ config: [import.meta.filename],
164
30
  },
165
31
  },
32
+
33
+ // 2. Production build: Clean, lean, zero devServer overrides or reverse proxies
34
+ ...(isProduction
35
+ ? {}
36
+ : {
37
+ devServer: {
38
+ port: 3001,
39
+ ...(hasCert
40
+ ? {
41
+ server: {
42
+ type: "https",
43
+ options: {
44
+ key: fs.readFileSync(keyFile),
45
+ cert: fs.readFileSync(certFile),
46
+ },
47
+ },
48
+ }
49
+ : {}),
50
+ allowedHosts: "all",
51
+ headers: {
52
+ "Access-Control-Allow-Origin": "*",
53
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
54
+ "Access-Control-Allow-Headers": "*",
55
+ "Access-Control-Allow-Private-Network": "true",
56
+ },
57
+ client: {
58
+ overlay: {
59
+ errors: true,
60
+ warnings: false,
61
+ runtimeErrors: false,
62
+ },
63
+ },
64
+ },
65
+ }),
166
66
  });