diff options
author | 2022-05-24 17:44:40 -0300 | |
---|---|---|
committer | 2022-05-24 15:44:40 -0500 | |
commit | 78e962f744a495b587bc691ad6b109543a5a5dde (patch) | |
tree | 8033b73487b0930f36b29eadf674083bfe234db6 | |
parent | 03b2ef4b672a60d29eb81782912e7dadffb38c9a (diff) | |
download | astro-78e962f744a495b587bc691ad6b109543a5a5dde.tar.gz astro-78e962f744a495b587bc691ad6b109543a5a5dde.tar.zst astro-78e962f744a495b587bc691ad6b109543a5a5dde.zip |
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 <nate@skypack.dev>
-rw-r--r-- | .changeset/orange-colts-march.md | 5 | ||||
-rw-r--r-- | packages/integrations/partytown/src/index.ts | 6 |
2 files changed, 9 insertions, 2 deletions
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: [], |