-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tailwindcss nesting support (#9529)
* Add tailwindcss nesting support * Update lockfile
- Loading branch information
Showing
9 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/tailwind': minor | ||
--- | ||
|
||
Adds `nesting` option to enable `tailwindcss/nesting` support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from '../../../astro/test/test-utils.js'; | ||
|
||
describe('Basic', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: new URL('./fixtures/basic/', import.meta.url), | ||
}); | ||
}); | ||
|
||
describe('build', () => { | ||
before(async () => { | ||
await fixture.build(); | ||
}); | ||
|
||
it('works', async () => { | ||
const astroChunkDir = await fixture.readdir('/_astro'); | ||
|
||
let css = ''; | ||
for (const file of astroChunkDir) { | ||
if (file.endsWith('.css')) { | ||
css += await fixture.readFile(`/_astro/${file}`); | ||
} | ||
} | ||
|
||
expect(css).to.include('box-sizing:border-box;'); // base css | ||
expect(css).to.include('text-red-500'); // class css | ||
expect(css).to.match(/\.a\[data-astro-cid-.*?\] \.b\[data-astro-cid-.*?\]/); // nesting | ||
}); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/integrations/tailwind/test/fixtures/basic/astro.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { fileURLToPath } from 'node:url'; | ||
import { defineConfig } from 'astro/config'; | ||
import tailwind from '@astrojs/tailwind'; | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
tailwind({ | ||
configFile: fileURLToPath(new URL('./tailwind.config.js', import.meta.url)), | ||
nesting: true | ||
}), | ||
] | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/integrations/tailwind/test/fixtures/basic/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@test/tailwind-basic", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/tailwind": "workspace:*" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/integrations/tailwind/test/fixtures/basic/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="text-red-500">red</div> | ||
|
||
<div class="a"> | ||
<div class="b">nested blue</div> | ||
</div> | ||
|
||
<style> | ||
.a { | ||
.b { | ||
color: blue; | ||
} | ||
} | ||
</style> |
6 changes: 6 additions & 0 deletions
6
packages/integrations/tailwind/test/fixtures/basic/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import path from 'node:path'; | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
export default { | ||
content: [path.join(__dirname, 'src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}')], | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.