Giter Site home page Giter Site logo

antingle / swiftytailwind Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tuist/swiftytailwind

0.0 0.0 0.0 40 KB

๐Ÿ’‡ A Swift Package to pull and run Tailwind from a Swift process

Home Page: https://swiftytailwind.tuist.io

License: MIT License

Swift 100.00%

swiftytailwind's Introduction

SwiftyTailwind ๐Ÿƒ

All Contributors

Netlify Status SwiftyTailwind

SwiftyTailwind is a Swift Package to lazily download and run the Tailwind CLI from a Swift project (e.g. Vapor app or Publish project).

Usage

First, you need to add SwiftyTailwind as a dependency in your project's Package.swift:

.package(url: "https://github.com/tuist/SwiftyTailwind.git", .upToNextMinor(from: "0.5.0"))

Once added, you'll create an instance of SwiftyTailwind specifying the version you'd like to use and where you'd like it to be downloaded.

let tailwind = SwiftyTailwind(version: .latest, directory: "./cache")

If you don't pass any argument, it defaults to the latest version in the system's default temporary directory. If you work in a team, we recommend fixing the version to minimize non-determinism across environments.

Initializing a tailwind.config.js

You can create a tailwind.config.js configuration file by running the initialize function on the SwiftyTailwind instance:

try await tailwind.initialize()

Check out all the available options in the documentation.

Running Tailwind

To run Tailwind against a project, you can use the run function:

try await subject.run(input: inputCSSPath, output: outputCSSPath, options: .content("views/**/*.html"))

If you'd like Tailwind to keep watching for file changes, you can pass the .watch option:

try await subject.run(input: inputCSSPath, 
                      output: outputCSSPath, 
                      options: .watch, .content("views/**/*.html"))

Check out all the available options in the documentation.

Integrating with Vapor

You can integrate this with Vapor by setting up a tailwind.swift

import SwiftyTailwind
import TSCBasic
import Vapor

func tailwind(_ app: Application) async throws {
  let resourecesDirectory = try AbsolutePath(validating: app.directory.resourcesDirectory)
  let publicDirectory = try AbsolutePath(validating: app.directory.publicDirectory)

  let tailwind = SwiftyTailwind()
  try await tailwind.run(
    input: .init(validating: "Styles/app.css", relativeTo: resourecesDirectory),
    output: .init(validating: "styles/app.generated.css", relativeTo: publicDirectory),
    options: .content("\(app.directory.viewsDirectory)/**/*.leaf")
  )
}

Then in configure.swift

try await tailwind(app)
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))

And in your index.leaf

<link rel="stylesheet" href="/styles/app.generated.css" />

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Chris
Chris

๐Ÿ–‹
William Sedlacek
William Sedlacek

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

swiftytailwind's People

Contributors

pepicrft avatar renovate[bot] avatar allcontributors[bot] avatar wsedlacek avatar csjones avatar jagreenwood avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.