diff options
author | 2025-03-04 14:27:55 +0700 | |
---|---|---|
committer | 2025-03-04 07:27:55 +0000 | |
commit | 5c0e0eaa908bbfd6705eb950713c26c9ee0bd32d (patch) | |
tree | 76ef040a333694c5ad2dc65ccb5560ce2081b32e | |
parent | a001a75d6ec08378d607531dc73959bf0a9e079e (diff) | |
download | astro-5c0e0eaa908bbfd6705eb950713c26c9ee0bd32d.tar.gz astro-5c0e0eaa908bbfd6705eb950713c26c9ee0bd32d.tar.zst astro-5c0e0eaa908bbfd6705eb950713c26c9ee0bd32d.zip |
feat(partytown): allow overriding `copyLibFiles.dest` in `astro:build:done` hook with the `lib` option (#13109)
* Support overriding copyLibFiles.dest in stro:build:done hook with lib option, defaulting to ~partytown. Remove leading '/' to match ileURLToPath.
* Support overriding copyLibFiles.dest in stro:build:done hook with lib option, defaulting to ~partytown. Remove leading '/' to match ileURLToPath.
* Update .changeset/plenty-coins-destroy.md
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
* Update packages/integrations/partytown/src/index.ts
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
* feat(stro:server:setup): add option for config.lib path
---------
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: twodft <64566069+twodft@users.noreply.github.com>
Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com>
-rw-r--r-- | .changeset/plenty-coins-destroy.md | 15 | ||||
-rw-r--r-- | packages/integrations/partytown/src/index.ts | 11 |
2 files changed, 22 insertions, 4 deletions
diff --git a/.changeset/plenty-coins-destroy.md b/.changeset/plenty-coins-destroy.md new file mode 100644 index 000000000..95aa146d4 --- /dev/null +++ b/.changeset/plenty-coins-destroy.md @@ -0,0 +1,15 @@ +--- +'@astrojs/partytown': patch +--- + +Adds support for `config.lib`, which allows changing the destination of the files: + +```diff +export default defineConfig({ + integrations: [partytown({ + config: { ++ lib: '/assets/lib/~partytown/'; + } + })] +}) +``` diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index f2ffbfea4..cefe3ab47 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -37,7 +37,7 @@ export default function createPlugin(options?: PartytownOptions): AstroIntegrati injectScript('head-inline', partytownSnippetHtml); }, 'astro:server:setup': ({ server }) => { - const lib = `/~partytown/`; + const lib = options?.config?.lib ?? `/~partytown/`; server.middlewares.use( sirv(partytownLibDirectory, { mount: lib, @@ -48,9 +48,12 @@ export default function createPlugin(options?: PartytownOptions): AstroIntegrati ); }, 'astro:build:done': async ({ dir }) => { - await copyLibFiles(fileURLToPath(new URL('~partytown', dir)), { - debugDir: options?.config?.debug ?? false, - }); + await copyLibFiles( + fileURLToPath(new URL(options?.config?.lib?.replace(/^\/?/, '') ?? '~partytown', dir)), + { + debugDir: options?.config?.debug ?? false, + }, + ); }, 'astro:build:ssr': async ({ manifest }) => { const dirpath = libDirPath({ debugDir: false }); |