diff --git a/packages/website/src/components/codeblock.mdx b/packages/website/src/components/codeblock.mdx index 1becde03..c6ffa00a 100644 --- a/packages/website/src/components/codeblock.mdx +++ b/packages/website/src/components/codeblock.mdx @@ -4,7 +4,10 @@ title: Setup Codeblock ```ts import * as Spotlight from '@spotlightjs/overlay'; -Spotlight.init(); + +if (import.meta.env.DEV) { + Spotlight.init(); +} ``` ```shell diff --git a/packages/website/src/content/docs/about.mdx b/packages/website/src/content/docs/about.mdx index 12e05602..e0ffb38c 100644 --- a/packages/website/src/content/docs/about.mdx +++ b/packages/website/src/content/docs/about.mdx @@ -30,7 +30,11 @@ Registering Spotlight in your frontend application: ```typescript import * as Spotlight from '@spotlightjs/overlay'; -Spotlight.init(); + +// only load Spotlight in dev +if (process.env.NODE_ENV === "development") { + Spotlight.init(); +} ``` Running the sidecar in the background: diff --git a/packages/website/src/content/docs/setup/index.mdx b/packages/website/src/content/docs/setup/index.mdx index be5b6e06..58c7f9bd 100644 --- a/packages/website/src/content/docs/setup/index.mdx +++ b/packages/website/src/content/docs/setup/index.mdx @@ -22,31 +22,49 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'; ```sh - npm add --save-dev @spotlightjs/overlay + npm add @spotlightjs/overlay ``` ```sh - pnpm add -D @spotlightjs/overlay + pnpm add @spotlightjs/overlay ``` ```sh - yarn add @spotlightjs/overlay -D + yarn add @spotlightjs/overlay ``` -Inject Spotlight into your application: +:::note +We're loading Spotlight with production dependencies as the import is static, but the expectation is it will be tree-shaken out using the environment test. +::: -```js -import * as Spotlight from '@spotlightjs/overlay'; +Inject Spotlight into your application: -// only load Spotlight in dev -if (process.env.NODE_ENV === "development") { - Spotlight.init(); -} -``` + + + ```js + import * as Spotlight from '@spotlightjs/overlay'; + + // only load Spotlight in dev + if (import.meta.env.DEV) { + Spotlight.init(); + } + ``` + + + ```js + import * as Spotlight from '@spotlightjs/overlay'; + + // only load Spotlight in dev + if (process.env.NODE_ENV === "development") { + Spotlight.init(); + } + ``` + + Upon loading your UI you should now see the Spotlight toolbar in bottom-right corner of your application.