Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-towns-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes `assetsPrefix` not being available on `build` from `astro:config/server`.
1 change: 1 addition & 0 deletions packages/astro/src/manifest/virtual-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const build = {
server: new URL(manifest.buildServerDir),
client: new URL(manifest.buildClientDir),
format: manifest.buildFormat,
assetsPrefix: manifest.assetsPrefix,
};

const cacheDir = new URL(manifest.cacheDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/types/public/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ServerDeserializedManifest = Pick<
> &
DeserializedDirs & {
i18n: AstroConfig['i18n'];
build: Pick<AstroConfig['build'], 'server' | 'client' | 'format'>;
build: Pick<AstroConfig['build'], 'server' | 'client' | 'format' | 'assetsPrefix'>;
root: URL;
image: Pick<AstroConfig['image'], 'objectFit' | 'objectPosition' | 'layout'>;
};
Expand Down
3 changes: 3 additions & 0 deletions packages/astro/test/fixtures/astro-manifest/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { defineConfig } from "astro/config";

// https://astro.build/config
export default defineConfig({
build: {
assetsPrefix: 'https://cdn.example.com',
},
site: "https://astro.build/",
i18n: {
locales: ["en", "fr"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ import { root, outDir, srcDir, build, cacheDir } from "astro:config/server";
<p id="cache-dir">{cacheDir}</p>
<p id="build-client">{build.client}</p>
<p id="build-server">{build.server}</p>
<p id="build-assets-prefix">{build.assetsPrefix}</p>
</body>
</html>
2 changes: 2 additions & 0 deletions packages/astro/test/serializeManifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('astro:config/server', () => {
.text()
.endsWith('/dist/serializeManifest-when-the-experimental-flag-is-enabled-in/server/'),
);
assert.equal($('#build-assets-prefix').text(), 'https://cdn.example.com');
// URL
assert.equal($('#root-url').text(), 'true');
});
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('astro:config/server', () => {
.text()
.endsWith('/dist/serializeManifest-when-the-experimental-flag-is-enabled-in-ssr/server/'),
);
assert.equal($('#build-assets-prefix').text(), 'https://cdn.example.com');
// URL
assert.equal($('#root-url').text(), 'true');
});
Expand Down
Loading