Skip to content

Commit 91f27d2

Browse files
authored
Merge pull request #14 from xHomu/patch-2
Update README.md for lazy loading RDT
2 parents 7391ea6 + bfa3a53 commit 91f27d2

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,22 @@ To install and utilize Remix Development Tools, follow these steps:
3838
1. Install the package via npm:
3939

4040
```bash
41-
npm install remix-development-tools
41+
npm install remix-development-tools -D
4242
```
4343

4444
2. Add the following to your application `root.tsx` file:
4545

4646
```diff
47+
// We'll lazy load RemixDevTools to ensure it doesn't contribute to production bundle size
48+
+ import { lazy } from "react";
4749
+ import rdtStylesheet from "remix-development-tools/stylesheet.css";
48-
+ import { RemixDevTools } from "remix-development-tools";
50+
+ const RemixDevTools =
51+
+ process.env.NODE_ENV === "development"
52+
+ ? React.lazy(() => import("remix-development-tools").then(({ RemixDevTools }) => ({ default: RemixDevTools })))
53+
+ : undefined;
4954

5055
+ export const links: LinksFunction = () => [
51-
+ ...(rdtStylesheet ? [{ rel: "stylesheet", href: rdtStylesheet }] : []),
56+
+ ...(rdtStylesheet && process.env.NODE_ENV === "development" ? [{ rel: "stylesheet", href: rdtStylesheet }] : []),
5257
+ ];
5358

5459

@@ -68,7 +73,7 @@ export default function App() {
6873
<ScrollRestoration />
6974
<Scripts />
7075
<LiveReload />
71-
+ <RemixDevTools />
76+
+ {RemixDevTools && <RemixDevTools />}
7277
</body>
7378
</html>
7479
);

0 commit comments

Comments
 (0)