Skip to content

Commit 6146d68

Browse files
authored
feat: play ground (#50)
* feat: play ground * fix: ignore msw/browser in server env of build process * fix: vercel deploy error because of root dir and pnpm local workspaces * fix: update lock
1 parent d0fe610 commit 6146d68

File tree

8 files changed

+85
-8
lines changed

8 files changed

+85
-8
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import { MSWDevTool } from "msw-dev-tool";
4+
import { Button } from "nextra/components";
5+
import "msw-dev-tool/msw-dev-tool.css";
6+
import { Terminal } from "lucide-react";
7+
8+
export const DevToolTrigger = () => {
9+
return (
10+
<div className="w-full py-4 flex justify-center items-center">
11+
<MSWDevTool
12+
trigger={
13+
<Button className="px-4 py-2 rounded-lg bg-gradient-to-r from-orange-500 to-amber-600 text-white font-medium shadow-md hover:shadow-xl hover:bg-gradient-to-r hover:from-orange-400 hover:to-amber-500 transition-all duration-200 border border-orange-500/30 hover:border-orange-400/70 flex items-center gap-2">
14+
<Terminal />
15+
Open msw-dev-tool
16+
</Button>
17+
}
18+
/>
19+
</div>
20+
);
21+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
description: msw-dev-tool playground
3+
---
4+
5+
import { DevToolTrigger } from "./_components/DevToolTrigger";
6+
7+
# Playground
8+
9+
> Use `msw-dev-tool` in playground 🚀
10+
11+
<DevToolTrigger />
12+
13+
## Example Apis
14+
15+
🚧 **Coming Soon** 🚧
16+
17+
I'm currently preparing API examples. Please check back later!
18+
A variety of useful API examples with use cases will be added here soon.

packages/docs/mock/browser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { setupDevToolWorker } from "msw-dev-tool";
2+
3+
export const worker = setupDevToolWorker();

packages/docs/next.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ const withNextra = nextra({
66
});
77

88
const nextConfig: NextConfig = withNextra({
9-
/* config options here */
9+
/**
10+
* This is required for the docs to use msw-dev-tool in production.
11+
* The build works in a node environment, but msw/browser should be used strictly in a browser environment.
12+
* However, build checks all browser packages that are statically imported.
13+
*/
14+
webpack: (config, { isServer }) => {
15+
if (isServer) {
16+
config.resolve.alias["msw/browser"] = false;
17+
}
18+
return config;
19+
},
1020
});
1121

1222
export default nextConfig;

packages/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"clsx": "^2.1.1",
1414
"lucide-react": "^0.479.0",
1515
"msw": "^2.7.0",
16-
"msw-dev-tool": "workspace:*",
16+
"msw-dev-tool": "latest",
1717
"next": "15.2.1",
1818
"nextra": "^4.2.16",
1919
"nextra-theme-docs": "^4.2.16",

packages/msw-dev-tool/src/lib/handlerStore.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use client";
2-
31
import { SetupWorker } from "msw/browser";
42
import { create } from "zustand";
53
import { FlattenHandler, Handler, HttpHandlerBehavior } from "./type";

packages/msw-dev-tool/src/ui/MSWDevTool.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use client";
2-
31
import React, { ReactNode } from "react";
42
import { Flex } from "@radix-ui/themes";
53
import { Drawer } from "vaul";

pnpm-lock.yaml

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)