@juncha9/rr7-build-fix
v0.0.1
Published
Fix Windows backslash path separators (assetsBuildDirectory) in React Router 7 SSR build output
Maintainers
Readme
@juncha9/rr7-build-fix
Fix Windows backslash path separators in React Router 7 SSR build output.
When you run react-router build on Windows, the server bundle declares:
var assetsBuildDirectory = "build\\client";The backslash separator breaks path handling on POSIX servers (e.g. Linux deploys). This CLI rewrites only that assignment to use a forward slash:
var assetsBuildDirectory = "build/client";It is surgical — it touches only the assetsBuildDirectory = "..." assignment, so
unrelated regex/pattern escapes elsewhere in the bundle (e.g. "\\d{6}") are left intact.
Running it twice is safe (idempotent).
Installation
npm install --save-dev @juncha9/rr7-build-fixUsage
Run with no arguments to fix server/index.js in the known build directories
(build/ and build_test/) — whichever exist:
npx rr7-build-fixWire it into your build scripts:
"scripts": {
"build:prod": "react-router build --mode production && rr7-build-fix",
"build:test": "react-router build --mode testprod && rr7-build-fix"
}Target a specific build directory or file:
rr7-build-fix build_test # fixes build_test/server/index.js
rr7-build-fix build/server/index.js # fixes the file directly
rr7-build-fix build build_test # multiple targetsA directory argument is resolved to <dir>/server/index.js; a file argument is used as-is.
Programmatic API
import { fixAssetsBuildPath } from "@juncha9/rr7-build-fix";
const result = fixAssetsBuildPath("build/server/index.js");
// { filePath, changed, before?, after? }License
MIT
