Skip to content

Commit

Permalink
Add base config option to partytown snippet generation (#3437)
Browse files Browse the repository at this point in the history
* fix: add base config option to partytown snippet generation

* add changeset

* fix: handle config.base for partytown

Co-authored-by: Nate Moore <nate@skypack.dev>
  • Loading branch information
caioferrarezi and Nate Moore authored May 24, 2022
1 parent 03b2ef4 commit 78e962f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-colts-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/partytown': patch
---

Fix partytown script generation to get astro base config option
6 changes: 4 additions & 2 deletions packages/integrations/partytown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 78e962f

Please sign in to comment.