-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add tailwindcss nesting support #9529
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're starting to have lots of options here, could it be better to have a single object instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an internal function so not a big deal. Going to merge this in but feel free to refactor if you'd like!