forked from remix-run/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remix-dev/vite): add buildDirectory and manifest options (remix-…
- Loading branch information
1 parent
bce34c1
commit 10fcf5b
Showing
10 changed files
with
288 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@remix-run/dev": patch | ||
--- | ||
|
||
Vite: Add `manifest` option to Vite plugin to enable writing a `manifest.json` file to the build directory | ||
|
||
**This is a breaking change for consumers of the Vite plugin's "server bundles" feature.** | ||
|
||
The `build/server/bundles.json` file has been superseded by the more general `build/manifest.json`. While the old server bundles manifest was always written to disk when generating server bundles, the build manifest file must be explicitly enabled via the `manifest` option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
"@remix-run/dev": patch | ||
--- | ||
|
||
Vite: Add new `buildDirectory` option with a default value of `"build"`. This replaces the old `assetsBuildDirectory` and `serverBuildDirectory` options which defaulted to `"build/client"` and `"build/server"` respectively. | ||
|
||
**This is a breaking change for consumers of the Vite plugin that were using the `assetsBuildDirectory` and `serverBuildDirectory` options.** | ||
|
||
The Remix Vite plugin now builds into a single directory containing `client` and `server` directories. If you've customized your build output directories, you'll need to migrate to the new `buildDirectory` option, e.g. | ||
|
||
```diff | ||
import { unstable_vitePlugin as remix } from "@remix-run/dev"; | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
remix({ | ||
- serverBuildDirectory: "dist/server", | ||
- assetsBuildDirectory: "dist/client", | ||
+ buildDirectory: "dist", | ||
}) | ||
], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import { test, expect } from "@playwright/test"; | ||
import getPort from "get-port"; | ||
|
||
import { createProject, viteBuild, VITE_CONFIG } from "./helpers/vite.js"; | ||
|
||
function createRoute(path: string) { | ||
return { | ||
[`app/routes/${path}`]: ` | ||
export default function Route() { | ||
return <p>Path: ${path}</p>; | ||
} | ||
`, | ||
}; | ||
} | ||
|
||
const TEST_ROUTES = [ | ||
"_index.tsx", | ||
"parent-route.tsx", | ||
"parent-route.child-route.tsx", | ||
]; | ||
|
||
const files = { | ||
"app/root.tsx": ` | ||
import { Links, Meta, Outlet, Scripts, LiveReload } from "@remix-run/react"; | ||
export default function Root() { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Outlet /> | ||
<Scripts /> | ||
<LiveReload /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
`, | ||
...Object.assign({}, ...TEST_ROUTES.map(createRoute)), | ||
}; | ||
|
||
test.describe(() => { | ||
let cwd: string; | ||
let devPort: number; | ||
|
||
test.beforeAll(async () => { | ||
devPort = await getPort(); | ||
cwd = await createProject({ | ||
"vite.config.ts": await VITE_CONFIG({ | ||
port: devPort, | ||
pluginOptions: "{ manifest: true }", | ||
}), | ||
...files, | ||
}); | ||
|
||
await viteBuild({ cwd }); | ||
}); | ||
|
||
test("Vite / build manifest", async () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(path.join(cwd, "build/manifest.json"), "utf8")) | ||
).toEqual({ | ||
routes: { | ||
root: { | ||
file: "root.tsx", | ||
id: "root", | ||
path: "", | ||
}, | ||
"routes/_index": { | ||
file: "routes/_index.tsx", | ||
id: "routes/_index", | ||
index: true, | ||
parentId: "root", | ||
}, | ||
"routes/parent-route": { | ||
file: "routes/parent-route.tsx", | ||
id: "routes/parent-route", | ||
parentId: "root", | ||
path: "parent-route", | ||
}, | ||
"routes/parent-route.child-route": { | ||
file: "routes/parent-route.child-route.tsx", | ||
id: "routes/parent-route.child-route", | ||
parentId: "routes/parent-route", | ||
path: "child-route", | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.