Skip to content

Commit

Permalink
Allow further configuration of partytown integration
Browse files Browse the repository at this point in the history
  • Loading branch information
simontong committed Jun 28, 2022
1 parent 037be5f commit 0f67262
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/integrations/partytown/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { partytownSnippet } from '@builder.io/partytown/integration';
import { partytownSnippet, PartytownConfig } from '@builder.io/partytown/integration';
import { copyLibFiles, libDirPath } from '@builder.io/partytown/utils';
import type { AstroConfig, AstroIntegration } from 'astro';
import * as fs from 'fs';
Expand All @@ -10,10 +10,7 @@ const resolve = createRequire(import.meta.url).resolve;

type PartytownOptions =
| {
config?: {
forward?: string[];
debug?: boolean;
};
config?: PartytownConfig;
}
| undefined;

Expand All @@ -26,10 +23,13 @@ export default function createPlugin(options: PartytownOptions): AstroIntegratio
name: '@astrojs/partytown',
hooks: {
'astro:config:setup': ({ config: _config, command, injectScript }) => {
const lib = `${_config.base}~partytown/`;
const forward = options?.config?.forward || [];
const debug = options?.config?.debug || command === 'dev';
partytownSnippetHtml = partytownSnippet({ lib, debug, forward });
const partytownConfig: PartytownConfig = {
...options?.config,
lib: `${_config.base}~partytown/`,
forward: options?.config?.forward || [],
debug: options?.config?.debug || command === 'dev',
};
partytownSnippetHtml = partytownSnippet(partytownConfig);
injectScript('head-inline', partytownSnippetHtml);
},
'astro:config:done': ({ config: _config }) => {
Expand Down

0 comments on commit 0f67262

Please sign in to comment.