summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/metal-grapes-tickle.md5
-rw-r--r--packages/astro/src/core/build/static-build.ts9
-rw-r--r--packages/astro/test/fixtures/static build SSR/astro.config.mjs6
-rw-r--r--packages/astro/test/fixtures/static build SSR/package.json9
-rw-r--r--packages/astro/test/fixtures/static build SSR/public/asset.txt1
-rw-r--r--packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt1
-rw-r--r--packages/astro/test/static-build.test.js12
-rw-r--r--pnpm-lock.yaml10
8 files changed, 48 insertions, 5 deletions
diff --git a/.changeset/metal-grapes-tickle.md b/.changeset/metal-grapes-tickle.md
new file mode 100644
index 000000000..101dc5052
--- /dev/null
+++ b/.changeset/metal-grapes-tickle.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix SSR static build public files copying
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index bddf4ceca..5a49c5792 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -253,15 +253,14 @@ async function copyFiles(fromFolder: URL, toFolder: URL) {
cwd: fileURLToPath(fromFolder),
});
- // Make the directory
- await fs.promises.mkdir(toFolder, { recursive: true });
-
await Promise.all(
files.map(async (filename) => {
const from = new URL(filename, fromFolder);
const to = new URL(filename, toFolder);
- return fs.promises.copyFile(from, to);
- })
+ const lastFolder = new URL('./', to)
+ return fs.promises.mkdir(lastFolder, {recursive: true})
+ .then(()=>fs.promises.copyFile(from, to) )
+ })
);
}
diff --git a/packages/astro/test/fixtures/static build SSR/astro.config.mjs b/packages/astro/test/fixtures/static build SSR/astro.config.mjs
new file mode 100644
index 000000000..cf1980887
--- /dev/null
+++ b/packages/astro/test/fixtures/static build SSR/astro.config.mjs
@@ -0,0 +1,6 @@
+import { defineConfig } from 'astro/config';
+import nodejs from '@astrojs/node';
+
+export default defineConfig({
+ adapter: nodejs(),
+});
diff --git a/packages/astro/test/fixtures/static build SSR/package.json b/packages/astro/test/fixtures/static build SSR/package.json
new file mode 100644
index 000000000..658d40fa9
--- /dev/null
+++ b/packages/astro/test/fixtures/static build SSR/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "@test/static-build",
+ "version": "0.0.0",
+ "dependencies": {
+ "@astrojs/node": "workspace:*",
+ "@test/static-build-pkg": "workspace:*",
+ "astro": "workspace:*"
+ }
+}
diff --git a/packages/astro/test/fixtures/static build SSR/public/asset.txt b/packages/astro/test/fixtures/static build SSR/public/asset.txt
new file mode 100644
index 000000000..7d40b559f
--- /dev/null
+++ b/packages/astro/test/fixtures/static build SSR/public/asset.txt
@@ -0,0 +1 @@
+test asset
diff --git a/packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt b/packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt
new file mode 100644
index 000000000..7d40b559f
--- /dev/null
+++ b/packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt
@@ -0,0 +1 @@
+test asset
diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js
index cc6436138..994658787 100644
--- a/packages/astro/test/static-build.test.js
+++ b/packages/astro/test/static-build.test.js
@@ -168,3 +168,15 @@ describe('Static build', () => {
expect(found).to.equal(true, 'Found the log message');
});
});
+
+describe('Static build SSR', () => {
+
+ it('Copies public files', async () => {
+ const fixture = await loadFixture({
+ root: './fixtures/static build SSR/',
+ });
+ await fixture.build()
+ const asset = await fixture.readFile('/client/nested/asset2.txt');
+ });
+
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ee4bb073c..190872d7d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1102,6 +1102,16 @@ importers:
'@test/static-build-pkg': link:pkg
astro: link:../../..
+ packages/astro/test/fixtures/static build SSR:
+ specifiers:
+ '@astrojs/node': workspace:*
+ '@test/static-build-pkg': workspace:*
+ astro: workspace:*
+ dependencies:
+ '@astrojs/node': link:../../../../integrations/node
+ '@test/static-build-pkg': link:../static build/pkg
+ astro: link:../../..
+
packages/astro/test/fixtures/static build/pkg:
specifiers: {}
lspan='5' class='logmsg'> Fixes #6527 2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1 2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9 2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92 Fixes #6443 2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6 2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0 2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10 2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3 2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1 Co-authored-by: Colin McDonnell <colin@KennyM1.local> 2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36 * fix pg hang on end + hanging on query * remove dummy function * fix node-stream * add test * fix test * return error in test * fix test use once instead of on * fix OOM * generated * 💅 * 💅 2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64 * check if dependency matches workspace version * test * Update lockfile.zig * set resolution to workspace package id 2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18 * integrity padding * error message for bytes at end of struct