summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/plenty-coins-destroy.md15
-rw-r--r--packages/integrations/partytown/src/index.ts11
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 });