Add LICENSE and README files

This commit is contained in:
Shibo Lyu 2025-08-17 18:14:38 +08:00
parent 8fbeb20900
commit 7c848062ec
2 changed files with 66 additions and 0 deletions

9
LICENSE Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright © 2025 Shibo Lyu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

57
README.md Normal file
View file

@ -0,0 +1,57 @@
# SwiftTailwind
Use Tailwind CSS in your Swift projects, seemlessly integrated as a Build Tool Plugin.
## Usage
Add this package to your Swift project as a dependency using the Swift Package Manager.
```swift
dependencies: [
.package(url: "https://github.com/laosb/SwiftTailwind.git", from: "4.1.12"),
],
```
Then, in your `Package.swift` file, add the plugin to your target:
```swift
targets: [
.target(
name: "YourTargetName",
plugins: [
.plugin(name: "TailwindCSS", package: "SwiftTailwind")
]
)
]
```
Place your Tailwind CSS entrypoint file at `Tailwind.css` in your target. To integrate seamlessly with Swift Package Manager build process, SwiftTailwind requires defining your source files explicitly, and does not support `@source not` to exclude files. Instead, you can use `@source` to include specific files or directories.
```css
@import "tailwindcss" source(none);
@source "./Views";
@source "./Template.swift";
@source "./Static";
```
The plugin will automatically process your Tailwind CSS files during the build process, generating the necessary CSS output. The output will be named as `tw.css` and will be placed in the `TailwindCSS.bundle` directory within your target. You won't see it in your source tree, but it will be available to your build product as `Bundle.module.url(forResource: "TailwindCSS", withExtension: "bundle")`.
```swift
import Foundation
let cssFileURL = Bundle.module
.url(forResource: "TailwindCSS", withExtension: "bundle")!
.appending(component: "tw.css")
```
## About the binary blob
A binary artifact bundle will be downloaded from this repo's GitHub Releases. It contains the standalone version of Tailwind CSS CLI, which is used to process your Tailwind CSS files. This allows you to use Tailwind CSS without needing to install Node.js or npm in your Swift project.
It is built using [`Scripts/buildArtifactBundle.sh`](Scripts/buildArtifactBundle.sh), which pulls the specified version of Tailwind CSS CLI from their GitHub Releases and packages it into a Swift Package compatible format. It is then manually uploaded to this repository's GitHub Releases.
Any contributions to automate the artifact generation are welcome!
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.