diff --git a/Plugins/TailwindCSS/TailwindCSSBuildPlugin.swift b/Plugins/TailwindCSS/TailwindCSSBuildPlugin.swift index a1263cf..d13cd10 100644 --- a/Plugins/TailwindCSS/TailwindCSSBuildPlugin.swift +++ b/Plugins/TailwindCSS/TailwindCSSBuildPlugin.swift @@ -65,8 +65,10 @@ struct TailwindCSSBuildPlugin: BuildToolPlugin { .matches(of: sourceDeclarationRegex) .compactMap { String($0.output.1) } let sourceURLs: [URL] = sourcePaths.map { path in - target.directoryURL - .appending(component: path, directoryHint: .inferFromPath) + // Simplified handling: If ** is used, we just include everything in the directory. + let globlessPath = path.replacing(/\*\*.*/, with: "") + return target.directoryURL + .appending(component: globlessPath, directoryHint: .inferFromPath) .resolvingSymlinksInPath() } diff --git a/README.md b/README.md index c9254a1..f37554c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Place your Tailwind CSS entrypoint file at `Tailwind.css` in your target. To int ```css @import "tailwindcss" source(none); -@source "./Views"; +/* Note that as of writing, Tailwind doesn't scan .swift files by default, so you need to specify a glob pattern including the extension. */ +@source "./Views/**/*.swift"; @source "./Template.swift"; @source "./Static"; ``` diff --git a/Sources/SwiftTailwindExample/Folder/Template.swift b/Sources/SwiftTailwindExample/Folder/Template.swift new file mode 100644 index 0000000..61a9db7 --- /dev/null +++ b/Sources/SwiftTailwindExample/Folder/Template.swift @@ -0,0 +1,4 @@ +let template = +""" +
Test
+""" diff --git a/Sources/SwiftTailwindExample/Tailwind.css b/Sources/SwiftTailwindExample/Tailwind.css index 8655d00..8fd853b 100644 --- a/Sources/SwiftTailwindExample/Tailwind.css +++ b/Sources/SwiftTailwindExample/Tailwind.css @@ -5,3 +5,4 @@ @import "tailwindcss" source(none); @source "./Example.swift"; @source "./Folder"; +@source "./Folder/**/*.swift"; diff --git a/Tests/SwiftTailwindTests/Tests.swift b/Tests/SwiftTailwindTests/Tests.swift index 48f2835..008a9cf 100644 --- a/Tests/SwiftTailwindTests/Tests.swift +++ b/Tests/SwiftTailwindTests/Tests.swift @@ -17,6 +17,10 @@ struct SwiftTailwindExampleTests { generatedCSS?.contains("text-\\[\\#f05138\\]") == true, "Arbitary value class used in Test.html is generated." ) + #expect( + generatedCSS?.contains("bg-red-100") == true, + "Arbitary value class used in Folder/Template.swift is generated." + ) #expect( generatedCSS?.contains("bg-blue-500") == false, "Class not used is not generated."