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>
This commit is contained in:
parent
03b2ef4b67
commit
78e962f744
2 changed files with 9 additions and 2 deletions
5
.changeset/orange-colts-march.md
Normal file
5
.changeset/orange-colts-march.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/partytown': patch
|
||||
---
|
||||
|
||||
Fix partytown script generation to get astro base config option
|
|
@ -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: [],
|
||||
|
|
Loading…
Reference in a new issue