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

[ci] release #121

Merged
merged 1 commit into from
Jan 3, 2024
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: 0 additions & 5 deletions .changeset/slimy-donuts-lick.md

This file was deleted.

6 changes: 6 additions & 0 deletions packages/netlify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @astrojs/netlify

## 4.1.0

### Minor Changes

- [#120](https://github.com/withastro/adapters/pull/120) [`cf39b9d`](https://github.com/withastro/adapters/commit/cf39b9ddb3c3f7db563c67ac9a6e88857862b694) Thanks [@Skn0tt](https://github.com/Skn0tt)! - Adds opt-out option for Image CDN.

## 4.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/netlify/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@astrojs/netlify",
"description": "Deploy your site to Netlify",
"version": "4.0.2",
"version": "4.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
Expand Down
6 changes: 3 additions & 3 deletions packages/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export interface NetlifyIntegrationConfig {
/**
* If enabled, Netlify Image CDN is used for image optimization.
* This transforms images on-the-fly without impacting build times.
*
*
* If disabled, Astro's built-in image optimization is run at build-time instead.
*
*
* @default {true}
*/
imageCDN?: boolean
imageCDN?: boolean;
}

export default function netlifyIntegration(
Expand Down
52 changes: 26 additions & 26 deletions packages/netlify/test/functions/image-cdn.test.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import { describe } from 'node:test';
import { loadFixture } from '@astrojs/test-utils';
import { expect } from 'chai';
import { describe } from 'node:test';

describe('Image CDN', () => {
const root = new URL('./fixtures/middleware/', import.meta.url);

describe("when running outside of netlify", () => {
it("does not enable Image CDN", async () => {
const fixture = await loadFixture({ root });
describe('when running outside of netlify', () => {
it('does not enable Image CDN', async () => {
const fixture = await loadFixture({ root });
await fixture.build();

const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/_astro/astronaut.`)
})
})
const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/_astro/astronaut.`);
});
});

describe("when running inside of netlify", () => {
it("enables Netlify Image CDN", async () => {
process.env.NETLIFY = 'true'
const fixture = await loadFixture({ root });
describe('when running inside of netlify', () => {
it('enables Netlify Image CDN', async () => {
process.env.NETLIFY = 'true';
const fixture = await loadFixture({ root });
await fixture.build();

const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/.netlify/image`)
const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/.netlify/image`);

process.env.NETLIFY = undefined
})
process.env.NETLIFY = undefined;
});

it("respects image CDN opt-out", async () => {
process.env.NETLIFY = 'true'
process.env.DISABLE_IMAGE_CDN = 'true'
const fixture = await loadFixture({ root });
it('respects image CDN opt-out', async () => {
process.env.NETLIFY = 'true';
process.env.DISABLE_IMAGE_CDN = 'true';
const fixture = await loadFixture({ root });
await fixture.build();

const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/_astro/astronaut.`)
const astronautPage = await fixture.readFile('astronaut/index.html');
expect(astronautPage).contains(`src="/_astro/astronaut.`);

process.env.NETLIFY = undefined
process.env.DISABLE_IMAGE_CDN = undefined
})
})
process.env.NETLIFY = undefined;
process.env.DISABLE_IMAGE_CDN = undefined;
});
});
});