This plugin is intended for use with Vapor.
Add .package(url: "https://github.com/skyglassapp/TailwindCSS.git", from: "0.1.1") to your package dependencies and .plugin(name: "TailwindCSSBuild", package: "TailwindCSS") to your target plugins.
Add your tailwind.config.js to the root of the package and your index.css to your target source directory. All other static resources should also be added to the source directory and added to your target resources as .copy(_:).
When you build your target, Tailwind CSS will process your index.css and copy it to the root of your bundle alongside your other resources. Vapor's FileMiddleware normally loads static resources from the Public directory at the package root, so we need to have it load from the bundle instead:
app.middleware.use(try FileMiddleware(bundle: Bundle.module, publicDirectory: "/"))To release a new binary:
-
Create an artifact bundle containing the latest release of the Tailwind CSS standalone CLI:
tailwindcss.artifactbundle/ ├── info.json ├── tailwindcss-linux-x86 ├── tailwindcss-macos-arm64 └── tailwindcss-windows-x64.exeinfo.json{ "schemaVersion": "1.0", "artifacts": { "tailwindcss": { "version": "<version>", "type": "executable", "variants": [ { "path": "tailwindcss-macos-arm64", "supportedTriples": ["arm64-apple-macosx"] }, { "path": "tailwindcss-linux-x64", "supportedTriples": ["x86_64-unknown-linux-gnu"] }, { "path": "tailwindcss-windows-x64.exe", "supportedTriples": ["x86_64-unknown-windows-msvc"] } ] } } } -
Make sure Unix executables have their executable bit set:
chmod +x tailwindcss.artifactbundle/tailwindcss-linux-x64 chmod +x tailwindcss.artifactbundle/tailwindcss-macos-arm64
-
Compress the artifact bundle into a ZIP file:
zip -r tailwindcss_<tag>.artifactbundle.zip tailwindcss.artifactbundle
-
Draft a release on GitHub using the GitHub CLI:
gh release create <tag> tailwindcss_<tag>.artifactbundle.zip --title <tag> --generate-notes --draft
-
Get info about the asset:
gh release view <tag> --json assets
-
Copy the
apiUrlvalue and set it as theurlvalue of the binary target inPackage.swift, appending.zip. -
From the root of the Swift package, compute the checksum of the ZIP file:
swift package compute-checksum tailwindcss_<tag>.artifactbundle.zip
-
Copy the checksum and set it as the
checksumvalue of the binary target inPackage.swift. -
Commit and tag the repository, and push the commit and tag.
-
Publish the release:
gh release edit <tag> --draft=false