Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Missing Sharp error during build #8049

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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: 4 additions & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@
"srcset-parse": "^1.1.0",
"unified": "^10.1.2"
},
"peerDependencies": {
"sharp": "^0.32.1"
},
rishi-raj-jain marked this conversation as resolved.
Show resolved Hide resolved
"engines": {
"node": ">=18.14.1",
"npm": ">=6.14.0"
rishi-raj-jain marked this conversation as resolved.
Show resolved Hide resolved
"pnpm": ">=8.6.2"
}
}
20 changes: 20 additions & 0 deletions packages/astro/test/astro-sharp.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

describe('Sharp Default Setup', () => {
let fixture;

before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-sharp',
});
await fixture.build();
});

it('Serve optimized image', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('img').attr('src')).to.include('_astro');
});
});
8 changes: 8 additions & 0 deletions packages/astro/test/fixtures/astro-sharp/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
experimental: {
assets: true
},
});
8 changes: 8 additions & 0 deletions packages/astro/test/fixtures/astro-sharp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@test/astro-sharp",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
}
}
13 changes: 13 additions & 0 deletions packages/astro/test/fixtures/astro-sharp/src/assets/img.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions packages/astro/test/fixtures/astro-sharp/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
import { Image } from 'astro:assets';
// @ts-ignore
import myImage from "../assets/img.svg";

let title = 'My Page'
---

<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{title}</h1>
<Image src={myImage} width={750} height={250} format="avif" alt="descriptive text" />
</body>
</html>
10 changes: 6 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.