diff --git a/.changeset/small-bugs-prove.md b/.changeset/small-bugs-prove.md new file mode 100644 index 000000000..16a89271d --- /dev/null +++ b/.changeset/small-bugs-prove.md @@ -0,0 +1,34 @@ +--- +'astro': minor +--- + +Order Astro styles last, to override imported styles + +This fixes CSS ordering so that imported styles are placed *higher* than page/component level styles. This means that if you do: + +```astro +--- +import '../styles/global.css'; +--- + +``` + +The ` diff --git a/packages/astro/test/fixtures/css-order-import/src/pages/component.astro b/packages/astro/test/fixtures/css-order-import/src/pages/component.astro new file mode 100644 index 000000000..018ab1866 --- /dev/null +++ b/packages/astro/test/fixtures/css-order-import/src/pages/component.astro @@ -0,0 +1,19 @@ +--- +import One from '../components/One.astro'; +import Two from '../components/Two.astro'; +--- + + + Test + + + + + +

Test

+ + diff --git a/packages/astro/test/fixtures/css-order-import/src/pages/index.astro b/packages/astro/test/fixtures/css-order-import/src/pages/index.astro new file mode 100644 index 000000000..0843250c0 --- /dev/null +++ b/packages/astro/test/fixtures/css-order-import/src/pages/index.astro @@ -0,0 +1,16 @@ +--- +import '../styles/base.css'; +--- + + + Test + + + +

Test

+ + diff --git a/packages/astro/test/fixtures/css-order-import/src/styles/One.css b/packages/astro/test/fixtures/css-order-import/src/styles/One.css new file mode 100644 index 000000000..66d2bb71b --- /dev/null +++ b/packages/astro/test/fixtures/css-order-import/src/styles/One.css @@ -0,0 +1,3 @@ +body { + background: burlywood; +} diff --git a/packages/astro/test/fixtures/css-order-import/src/styles/base.css b/packages/astro/test/fixtures/css-order-import/src/styles/base.css new file mode 100644 index 000000000..828bff206 --- /dev/null +++ b/packages/astro/test/fixtures/css-order-import/src/styles/base.css @@ -0,0 +1,3 @@ +body { + background: green; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aaeec592c..67b08ecc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -349,7 +349,7 @@ importers: packages/astro: specifiers: - '@astrojs/compiler': ^0.24.0 + '@astrojs/compiler': ^0.25.0 '@astrojs/language-server': ^0.26.2 '@astrojs/markdown-remark': ^1.1.2 '@astrojs/telemetry': ^1.0.0 @@ -443,7 +443,7 @@ importers: yargs-parser: ^21.0.1 zod: ^3.17.3 dependencies: - '@astrojs/compiler': 0.24.0 + '@astrojs/compiler': 0.25.0 '@astrojs/language-server': 0.26.2 '@astrojs/markdown-remark': link:../markdown/remark '@astrojs/telemetry': link:../telemetry @@ -1584,6 +1584,12 @@ importers: dependencies: astro: link:../../.. + packages/astro/test/fixtures/css-order-import: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/custom-404: specifiers: astro: workspace:* @@ -3639,8 +3645,8 @@ packages: resolution: {integrity: sha512-vBMPy9ok4iLapSyCCT1qsZ9dK7LkVFl9mObtLEmWiec9myGHS9h2kQY2xzPeFNJiWXUf9O6tSyQpQTy5As/p3g==} dev: false - /@astrojs/compiler/0.24.0: - resolution: {integrity: sha512-xZ81C/oMfExdF18I1Tyd2BKKzBqO+qYYctSy4iCwH4UWSo/4Y8A8MAzV1hG67uuE7hFRourSl6H5KUbhyChv/A==} + /@astrojs/compiler/0.25.0: + resolution: {integrity: sha512-thJdIFuKT7f6uzxUs5d7qjh3g/L4kmlSfddAcbC62QEMy4H9N9fig3+FBwg9exUvXYcqOjZ/nC2PsGsVIqmZYA==} dev: false /@astrojs/language-server/0.26.2: