diff --git a/.changeset/chatty-dolls-visit.md b/.changeset/chatty-dolls-visit.md
deleted file mode 100644
index 6b9e53e88..000000000
--- a/.changeset/chatty-dolls-visit.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@astrojs/sitemap': minor
----
-
-Adds support to SSR routes to sitemap generation.
diff --git a/.changeset/friendly-fishes-sing.md b/.changeset/friendly-fishes-sing.md
deleted file mode 100644
index 9da10e6bf..000000000
--- a/.changeset/friendly-fishes-sing.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': minor
----
-
-Implement Inline Stylesheets RFC as experimental
diff --git a/.changeset/green-cups-hammer.md b/.changeset/green-cups-hammer.md
deleted file mode 100644
index 1492f8d3c..000000000
--- a/.changeset/green-cups-hammer.md
+++ /dev/null
@@ -1,21 +0,0 @@
----
-'astro': minor
----
-
-Implements a new class-based scoping strategy
-
-This implements the [Scoping RFC](https://github.com/withastro/roadmap/pull/543), providing a way to opt in to increased style specificity for Astro component styles.
-
-This prevents bugs where global styles override Astro component styles due to CSS ordering and the use of element selectors.
-
-To enable class-based scoping, you can set it in your config:
-
-```js
-import { defineConfig } from 'astro/config';
-
-export default defineConfig({
- scopedStyleStrategy: 'class'
-});
-```
-
-Note that the 0-specificity `:where` pseudo-selector is still the default strategy. The intent is to change `'class'` to be the default in 3.0.
diff --git a/.changeset/nine-geckos-act.md b/.changeset/nine-geckos-act.md
deleted file mode 100644
index 164dbbfd5..000000000
--- a/.changeset/nine-geckos-act.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': minor
----
-
-Support `` to output inline code HTML (no `pre` tag)
diff --git a/.changeset/pretty-bears-deliver.md b/.changeset/pretty-bears-deliver.md
deleted file mode 100644
index 2b8bfc818..000000000
--- a/.changeset/pretty-bears-deliver.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': minor
----
-
-New middleware API
diff --git a/.changeset/smooth-cows-jog.md b/.changeset/smooth-cows-jog.md
deleted file mode 100644
index 8c6d4563c..000000000
--- a/.changeset/smooth-cows-jog.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-'@astrojs/markdoc': patch
-'@astrojs/mdx': patch
-'@astrojs/markdown-remark': minor
-'astro': minor
----
-
-Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the `pre` tag, e.g. `
`. diff --git a/.changeset/twelve-feet-switch.md b/.changeset/twelve-feet-switch.md deleted file mode 100644 index b581fb4c3..000000000 --- a/.changeset/twelve-feet-switch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Ensure multiple cookies set in dev result in multiple set-cookie headers diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 0ce75e341..eac50154c 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,92 @@ # astro +## 2.4.1 + +### Patch Changes + +- [#6995](https://github.com/withastro/astro/pull/6995) [`71332cf96`](https://github.com/withastro/astro/commit/71332cf9697755884e5e2e63d6d2499cc2c5edd1) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Move sharpImageService and squooshImageService functions to `astro/config` so they can be imported + +## 2.4.0 + +### Minor Changes + +- [#6990](https://github.com/withastro/astro/pull/6990) [`818252acd`](https://github.com/withastro/astro/commit/818252acda3c00499cea51ffa0f26d4c2ccd3a02) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Generated optimized images are now cached inside the `node_modules/.astro/assets` folder. The cached images will be used to avoid doing extra work and speed up subsequent builds. + +- [#6659](https://github.com/withastro/astro/pull/6659) [`80e3d4d3d`](https://github.com/withastro/astro/commit/80e3d4d3d0f7719d8eae5435bba3805503057511) Thanks [@lilnasy](https://github.com/lilnasy)! - Implement Inline Stylesheets RFC as experimental + +- [#6771](https://github.com/withastro/astro/pull/6771) [`3326492b9`](https://github.com/withastro/astro/commit/3326492b94f76ed2b0154dd9b9a1a9eb883c1e31) Thanks [@matthewp](https://github.com/matthewp)! - Implements a new class-based scoping strategy + + This implements the [Scoping RFC](https://github.com/withastro/roadmap/pull/543), providing a way to opt in to increased style specificity for Astro component styles. + + This prevents bugs where global styles override Astro component styles due to CSS ordering and the use of element selectors. + + To enable class-based scoping, you can set it in your config: + + ```js + import { defineConfig } from 'astro/config'; + + export default defineConfig({ + scopedStyleStrategy: 'class', + }); + ``` + + Note that the 0-specificity `:where` pseudo-selector is still the default strategy. The intent is to change `'class'` to be the default in 3.0. + +- [#6959](https://github.com/withastro/astro/pull/6959) [`cac4a321e`](https://github.com/withastro/astro/commit/cac4a321e814fb805eb0e3ced469e25261a50885) Thanks [@bluwy](https://github.com/bluwy)! - Support `` to output inline code HTML (no `pre` tag) + +- [#6721](https://github.com/withastro/astro/pull/6721) [`831b67cdb`](https://github.com/withastro/astro/commit/831b67cdb8250f93f66e3b171fab024652bf80f2) Thanks [@ematipico](https://github.com/ematipico)! - Implements a new experimental middleware in Astro. + + The middleware is available under the following experimental flag: + + ```js + export default defineConfig({ + experimental: { + middleware: true, + }, + }); + ``` + + Or via CLI, using the new argument `--experimental-middleware`. + + Create a file called `middleware.{js,ts}` inside the `src` folder, and + export a `onRequest` function. + + From `astro/middleware`, use the `defineMiddleware` utility to take advantage of type-safety, and use + the `sequence` utility to chain multiple middleware functions. + + Example: + + ```ts + import { defineMiddleware, sequence } from 'astro/middleware'; + + const redirects = defineMiddleware((context, next) => { + if (context.request.url.endsWith('/old-url')) { + return context.redirect('/new-url'); + } + return next(); + }); + + const minify = defineMiddleware(async (context, next) => { + const repsonse = await next(); + const minifiedHtml = await minifyHtml(response.text()); + return new Response(minifiedHtml, { + status: 200, + headers: response.headers, + }); + }); + + export const onRequest = sequence(redirects, minify); + ``` + +- [#6932](https://github.com/withastro/astro/pull/6932) [`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the `pre` tag, e.g. `
`. + +### Patch Changes + +- [#6973](https://github.com/withastro/astro/pull/6973) [`0883fd487`](https://github.com/withastro/astro/commit/0883fd4875548a613df122f0b87a1ca8b7a7cf7d) Thanks [@matthewp](https://github.com/matthewp)! - Ensure multiple cookies set in dev result in multiple set-cookie headers + +- Updated dependencies [[`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7)]: + - @astrojs/markdown-remark@2.2.0 + ## 2.3.4 ### Patch Changes diff --git a/packages/astro/config.d.ts b/packages/astro/config.d.ts index f117c6345..33aebd4f7 100644 --- a/packages/astro/config.d.ts +++ b/packages/astro/config.d.ts @@ -1,6 +1,7 @@ type ViteUserConfig = import('vite').UserConfig; type ViteUserConfigFn = import('vite').UserConfigFn; type AstroUserConfig = import('./dist/@types/astro.js').AstroUserConfig; +type ImageServiceConfig = import('./dist/@types/astro.js').ImageServiceConfig; /** * See the full Astro Configuration API Documentation @@ -12,3 +13,14 @@ export function defineConfig(config: AstroUserConfig): AstroUserConfig; * Use Astro to generate a fully resolved Vite config */ export function getViteConfig(config: ViteUserConfig): ViteUserConfigFn; + +/** + * Return the configuration needed to use the Sharp-based image service + * See: https://docs.astro.build/en/guides/assets/#using-sharp + */ +export function sharpImageService(): ImageServiceConfig; + +/** + * Return the configuration needed to use the Squoosh-based image service + */ +export function squooshImageService(): ImageServiceConfig; diff --git a/packages/astro/config.mjs b/packages/astro/config.mjs index f39fb8abc..9f5883015 100644 --- a/packages/astro/config.mjs +++ b/packages/astro/config.mjs @@ -1 +1,15 @@ export { defineConfig, getViteConfig } from './dist/config/index.js'; + +export function sharpImageService() { + return { + entrypoint: 'astro/assets/services/sharp', + config: {}, + }; +} + +export function squooshImageService() { + return { + entrypoint: 'astro/assets/services/squoosh', + config: {}, + }; +} diff --git a/packages/astro/package.json b/packages/astro/package.json index 08ee274a6..1cc91c896 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "2.3.4", + "version": "2.4.1", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -112,7 +112,7 @@ "dependencies": { "@astrojs/compiler": "^1.4.0", "@astrojs/language-server": "^1.0.0", - "@astrojs/markdown-remark": "^2.1.4", + "@astrojs/markdown-remark": "^2.2.0", "@astrojs/telemetry": "^2.1.1", "@astrojs/webapi": "^2.1.1", "@babel/core": "^7.18.2", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 336b6ae97..74c7de0f8 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -430,6 +430,23 @@ export interface AstroUserConfig { */ outDir?: string; + /** + * @docs + * @name cacheDir + * @type {string} + * @default `"./node_modules/.astro"` + * @description Set the directory for caching build artifacts. Files in this directory will be used in subsequent builds to speed up the build time. + * + * The value can be either an absolute file system path or a path relative to the project root. + * + * ```js + * { + * cacheDir: './my-custom-cache-directory' + * } + * ``` + */ + cacheDir?: string; + /** * @docs * @name site @@ -518,8 +535,8 @@ export interface AstroUserConfig { * @name scopedStyleStrategy * @type {('where' | 'class')} * @default `'where'` - * @description * @version 2.4 + * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specifity increase. @@ -1051,6 +1068,7 @@ export interface AstroUserConfig { * assets: true, * }, * } + * ``` */ assets?: boolean; @@ -1060,8 +1078,8 @@ export interface AstroUserConfig { * @type {('always' | 'auto' | 'never')} * @default `never` * @description - * Control whether styles are sent to the browser in a separate css file or inlined into