diff --git a/.changeset/silent-books-train.md b/.changeset/silent-books-train.md new file mode 100644 index 000000000000..eec5b12825cc --- /dev/null +++ b/.changeset/silent-books-train.md @@ -0,0 +1,5 @@ +--- +'@astrojs/partytown': patch +--- + +Add config options for integration diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index 7f235b776f81..24b0288a752e 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -7,7 +7,14 @@ import { createRequire } from 'module'; import path from 'path'; const resolve = createRequire(import.meta.url).resolve; -export default function createPlugin(): AstroIntegration { +type PartytownOptions = { + config?: { + forward?: string[]; + debug?: boolean; + } +} | undefined; + +export default function createPlugin(options: PartytownOptions): AstroIntegration { let config: AstroConfig; let partytownSnippetHtml: string; const partytownEntrypoint = resolve('@builder.io/partytown/package.json'); @@ -16,7 +23,9 @@ export default function createPlugin(): AstroIntegration { name: '@astrojs/partytown', hooks: { 'astro:config:setup': ({ config: _config, command, injectScript }) => { - partytownSnippetHtml = partytownSnippet({ debug: command === 'dev' }); + const forward = options?.config?.forward || [] + const debug = options?.config?.debug || command === 'dev' + partytownSnippetHtml = partytownSnippet({ debug, forward }); injectScript('head-inline', partytownSnippetHtml); }, 'astro:config:done': ({ config: _config }) => {