Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]

- Support importing official plugins in CSS for v4 [#22](https://github.com/vormwald/jekyll-tailwindcss/pull/22) @imustafin

## [0.6.1] - 2025-02-13

- Expand the matcher to match additional valid tailwindcss imports [#21](https://github.com/vormwald/jekyll-tailwindcss/pull/21)
Expand Down
8 changes: 7 additions & 1 deletion lib/jekyll/converters/tailwindcss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def output_ext(ext)

def convert(content)
return content unless /@tailwind|@import ['"]tailwindcss/i.match?(content)
if content.include?("@tailwind") && config_path.nil?
if config_path.nil? && tailwind_v3_syntax?(content)
Jekyll.logger.error "Jekyll Tailwind:", "to use tailwind v3 you need to include a config path in _config.yml"
return content
end
Expand Down Expand Up @@ -46,6 +46,12 @@ def convert(content)

private

def tailwind_v3_syntax?(content)
return false if content.include?("@plugin")

content.include?("@tailwind")
end

def tailwindcss_env_options
# Without this ENV you'll get a warning about `Browserslist: caniuse-lite is outdated`
# Since we're using the CLI, we can't update the data, so we ignore it.
Expand Down
18 changes: 18 additions & 0 deletions spec/jekyll/converters/tailwindcss_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@
end
end

context "when using official plugins" do
let(:tailwindcss_content) do
# Example installation configuration for
# https://github.com/tailwindlabs/tailwindcss-typography
<<~TAILWINDCSS
@import "tailwindcss";
@plugin "@tailwindcss/typography";
TAILWINDCSS
end

it "does not produce errors" do
expect(Jekyll.logger).not_to receive(:error).with("Jekyll Tailwind:", /v3/)
expect(Jekyll.logger).to receive(:info).with("Jekyll Tailwind:", "Generating CSS")

converter.convert(tailwindcss_content)
end
end

context "when using TailwindCSS v3" do
let(:tailwindcss_content) do
<<~TAILWINDCSS
Expand Down