Skip to content

Commit 8a5b0c1

Browse files
lilnasysarah11918
andauthored
Switch build.inlineStylesheets default to auto (#8118)
* switch inlineStylesheets default * use previous default for astro/test * use previous default for content-collections-render.test.js * integrations: node, deno, mdx, markdown * typedocs: switch inlineStylesheets default * Update example to show non-default * add changeset * reword changeset --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
1 parent 2540fee commit 8a5b0c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+141
-18
lines changed

.changeset/smart-numbers-shout.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Astro is smarter about CSS! Small stylesheets are now inlined by default, and no longer incur the cost of additional requests to your server. Your visitors will have to wait less before they see your pages, especially those in remote locations or in a subway.
6+
7+
This may not be news to you if you had opted-in via the `build.inlineStylesheets` configuration. Stabilized in Astro 2.6 and set to "auto" by default for Starlight, this configuration allows you to reduce the number of requests for stylesheets by inlining them into <style> tags. The new default is "auto", which selects assets smaller than 4kB and includes them in the initial response.
8+
9+
To go back to the previous default behavior, change `build.inlineStylesheets` to "never".
10+
11+
```ts
12+
import { defineConfig } from 'astro/config';
13+
14+
export default defineConfig({
15+
build: {
16+
inlineStylesheets: 'never',
17+
},
18+
});
19+
```

packages/astro/src/@types/astro.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ export interface AstroUserConfig {
836836
* @docs
837837
* @name build.inlineStylesheets
838838
* @type {('always' | 'auto' | 'never')}
839-
* @default `never`
839+
* @default `auto`
840840
* @version 2.6.0
841841
* @description
842842
* Control whether project styles are sent to the browser in a separate css file or inlined into `<style>` tags. Choose from the following options:
@@ -847,7 +847,7 @@ export interface AstroUserConfig {
847847
* ```js
848848
* {
849849
* build: {
850-
* inlineStylesheets: `auto`,
850+
* inlineStylesheets: `never`,
851851
* },
852852
* }
853853
* ```

packages/astro/src/core/config/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ASTRO_CONFIG_DEFAULTS = {
2525
assets: '_astro',
2626
serverEntry: 'entry.mjs',
2727
redirects: true,
28-
inlineStylesheets: 'never',
28+
inlineStylesheets: 'auto',
2929
split: false,
3030
excludeMiddleware: false,
3131
},

packages/astro/test/alias-tsconfig-baseurl-only.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ describe('Aliases with tsconfig.json - baseUrl only', () => {
2929

3030
before(async () => {
3131
fixture = await loadFixture({
32+
// test suite was authored when inlineStylesheets defaulted to never
33+
build: { inlineStylesheets: 'never' },
3234
root: './fixtures/alias-tsconfig-baseurl-only/',
3335
});
3436
});

packages/astro/test/alias-tsconfig.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ describe('Aliases with tsconfig.json', () => {
2929

3030
before(async () => {
3131
fixture = await loadFixture({
32+
// test suite was authored when inlineStylesheets defaulted to never
33+
build: { inlineStylesheets: 'never' },
3234
root: './fixtures/alias-tsconfig/',
3335
});
3436
});

packages/astro/test/asset-url-base.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ describe('Asset URL resolution in build', () => {
1212
fixture = await loadFixture({
1313
root: './fixtures/asset-url-base/',
1414
site: 'http://example.com/sub/path/',
15+
// test suite was authored when inlineStylesheets defaulted to never
16+
build: { inlineStylesheets: 'never' },
1517
});
1618
await fixture.build();
1719
});
@@ -30,6 +32,8 @@ describe('Asset URL resolution in build', () => {
3032
root: './fixtures/asset-url-base/',
3133
site: 'http://example.com/sub/path/',
3234
base: '/another/base/',
35+
// test suite was authored when inlineStylesheets defaulted to never
36+
build: { inlineStylesheets: 'never' },
3337
});
3438
await fixture.build();
3539
});

packages/astro/test/astro-client-only.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ describe('Client only components', () => {
99
before(async () => {
1010
fixture = await loadFixture({
1111
root: './fixtures/astro-client-only/',
12+
// test suite was authored when inlineStylesheets defaulted to never
13+
build: { inlineStylesheets: 'never' },
1214
});
1315
await fixture.build();
1416
});
@@ -72,6 +74,8 @@ describe('Client only components subpath', () => {
7274
site: 'https://site.com',
7375
base: '/blog',
7476
root: './fixtures/astro-client-only/',
77+
// test suite was authored when inlineStylesheets defaulted to never
78+
build: { inlineStylesheets: 'never' },
7579
});
7680
await fixture.build();
7781
});

packages/astro/test/astro-css-bundling.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ describe('CSS Bundling', function () {
2626
before(async () => {
2727
fixture = await loadFixture({
2828
root: './fixtures/astro-css-bundling/',
29+
// test suite was authored when inlineStylesheets defaulted to never
30+
build: { inlineStylesheets: 'never' },
2931
});
3032
await fixture.build({ mode: 'production' });
3133
});
@@ -76,6 +78,9 @@ describe('CSS Bundling', function () {
7678
fixture = await loadFixture({
7779
root: './fixtures/astro-css-bundling/',
7880

81+
// test suite was authored when inlineStylesheets defaulted to never
82+
build: { inlineStylesheets: 'never' },
83+
7984
vite: {
8085
build: {
8186
rollupOptions: {

packages/astro/test/astro-directives.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ describe('Directives', async () => {
66
let fixture;
77

88
before(async () => {
9-
fixture = await loadFixture({ root: './fixtures/astro-directives/' });
9+
fixture = await loadFixture({
10+
root: './fixtures/astro-directives/',
11+
// test suite was authored when inlineStylesheets defaulted to never
12+
build: { inlineStylesheets: 'never' }
13+
});
1014
await fixture.build();
1115
});
1216

packages/astro/test/astro-head.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ describe('Head in its own component', () => {
1010
root: './fixtures/astro-head/',
1111
site: 'https://mysite.dev/',
1212
base: '/blog',
13+
// test suite was authored when inlineStylesheets defaulted to never
14+
build: { inlineStylesheets: 'never' },
1315
});
1416
await fixture.build();
1517
});

0 commit comments

Comments
 (0)