Skip to content

Commit

Permalink
Add options to partytown integration
Browse files Browse the repository at this point in the history
  • Loading branch information
rotate-mark committed May 16, 2022
1 parent 21d9d36 commit bb239e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-books-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/partytown': patch
---

Add config options for integration
13 changes: 11 additions & 2 deletions packages/integrations/partytown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 }) => {
Expand Down

0 comments on commit bb239e8

Please sign in to comment.