From 78e962f744a495b587bc691ad6b109543a5a5dde Mon Sep 17 00:00:00 2001 From: Caio Ferrarezi Date: Tue, 24 May 2022 17:44:40 -0300 Subject: [PATCH] Add base config option to partytown snippet generation (#3437) * fix: add base config option to partytown snippet generation * add changeset * fix: handle config.base for partytown Co-authored-by: Nate Moore --- .changeset/orange-colts-march.md | 5 +++++ packages/integrations/partytown/src/index.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/orange-colts-march.md diff --git a/.changeset/orange-colts-march.md b/.changeset/orange-colts-march.md new file mode 100644 index 000000000..825130de2 --- /dev/null +++ b/.changeset/orange-colts-march.md @@ -0,0 +1,5 @@ +--- +'@astrojs/partytown': patch +--- + +Fix partytown script generation to get astro base config option diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index 425a0bc76..789f974eb 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -25,18 +25,20 @@ 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({ debug, forward }); + partytownSnippetHtml = partytownSnippet({ lib, debug, forward }); injectScript('head-inline', partytownSnippetHtml); }, 'astro:config:done': ({ config: _config }) => { config = _config; }, 'astro:server:setup': ({ server }) => { + const lib = `${config.base}~partytown/`; server.middlewares.use( sirv(partytownLibDirectory, { - mount: '/~partytown', + mount: lib, dev: true, etag: true, extensions: [],