Skip to content

Commit 2383c75

Browse files
committed
test: add browser-only component example
1 parent 7a40ee7 commit 2383c75

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineConfig({
2323
tailwindcss(),
2424
react(),
2525
vitePluginUseCache(),
26+
vitePluginBrowserOnly(),
2627
rsc({
2728
entries: {
2829
client: './src/client.tsx',
@@ -176,3 +177,18 @@ function vitePluginUseCache(): Plugin[] {
176177
},
177178
]
178179
}
180+
181+
function vitePluginBrowserOnly(): Plugin[] {
182+
return [
183+
{
184+
name: 'browser-only-component',
185+
load(id: string) {
186+
if (id.endsWith('?browser-only')) {
187+
this.environment.name === 'ssr'
188+
this.environment.name === 'rsc'
189+
this.environment.name === 'client'
190+
}
191+
},
192+
},
193+
]
194+
}

0 commit comments

Comments
 (0)