-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloudflare): support "compile-time" only image config for astro:…
…assets
- Loading branch information
1 parent
c365926
commit d30a95e
Showing
12 changed files
with
1,299 additions
and
975 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/cloudflare': minor | ||
--- | ||
|
||
TBA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect } from 'chai'; | ||
import { readFileSync } from 'node:fs'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { astroCli } from './_test-utils.js'; | ||
|
||
const root = new URL('./fixtures/assets-compile-time/', import.meta.url); | ||
|
||
describe('AssetsCompileTime', () => { | ||
it('has correct image service', async () => { | ||
await astroCli(fileURLToPath(root), 'build'); | ||
|
||
const outFileToCheck = readFileSync(fileURLToPath(new URL('dist/_worker.js', root)), 'utf-8'); | ||
expect(outFileToCheck).to.not.include('sharp') | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/cloudflare/test/fixtures/assets-compile-time/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import cloudflare from '@astrojs/cloudflare'; | ||
|
||
export default defineConfig({ | ||
output: 'server', | ||
adapter: cloudflare({ | ||
imageService: 'compile', | ||
}), | ||
}); | ||
|
||
// imageService: "compile", is equivalent to: | ||
// { | ||
// service: { entrypoint: 'astro/assets/services/sharp', config: {} }, | ||
// domains: [], | ||
// remotePatterns: [], | ||
// endpoint: '@astrojs/cloudflare/image-endpoint' | ||
// } |
12 changes: 12 additions & 0 deletions
12
packages/cloudflare/test/fixtures/assets-compile-time/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@test/astro-cloudflare-assets-compile-time", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/cloudflare": "workspace:*", | ||
"astro": "^3.5.6" | ||
}, | ||
"devDependencies": { | ||
"sharp": "^0.32.6" | ||
} | ||
} |
Binary file added
BIN
+868 KB
packages/cloudflare/test/fixtures/assets-compile-time/src/assets/lighthouse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions
2
packages/cloudflare/test/fixtures/assets-compile-time/src/env.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference path="../.astro/types.d.ts" /> | ||
/// <reference types="astro/client" /> |
7 changes: 7 additions & 0 deletions
7
packages/cloudflare/test/fixtures/assets-compile-time/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
export const prerender = true; | ||
import { Image } from "astro:assets"; | ||
import lighthouse from "../assets/lighthouse.jpg"; | ||
--- | ||
<Image src={lighthouse} width="512" quality="100" alt="Lighthouse" /> |
Oops, something went wrong.