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: {}