Git Product home page Git Product logo

tailwind-yew-builder's Introduction

Tailwind builder

Released under the MIT License.

Builds Tailwind CSS using docker, especially for yew or other rust and wasm style buildouts.

It expects your source files to be in $SOURCE_CODE/src/**/*.rs and $SOURCE_CODE/index.html.

USAGE

In your brand new yew project:

  1. git submodule add https://github.com/matiu2/tailwind-yew-builder.git
  2. git submodule init You should now have a sub directory called tailwind-yew-builder

Manual run (dev builds)

You only need to run it once and it'll generate the latest file - then you just keep using it while developing

  1. cd tailwind-yew-builder
  2. docker-compose up dev (This may take a while the first time, as it pulls the image from the docker hub) The output is in output/tailwind.css

Production / release

You could probably include this in your build.rs - but I haven't tried it yet, but the manual run is:

  1. cd tailwind-yew-builder
  2. docker-compose up prod (This may take a while the first time, as it pulls the image from the docker hub, although it's the same image as dev so if you already ran dev, it should be quick) The output is in output/tailwind.css

It'll search through your yew app root:

  • src/**/*.rs
  • index.html

..and regex all the files, looking for things that match tailwind.css's class names. Anything it doesn't find, will not make it into the tailwind.css file. Also, with prod builds, the tailwind.css file is minified/cleaned.

Production, but kind of still working on it

  1. cd tailwind-yew-builder
  2. docker-compose up watch It'll watch for file changes and re-run the prod script when they happen

This uses the input/watch.sh script. If you want to watch a different set of files for changes, you can change this script.


Using the output tailwind.css file

If you're using trunk to build your yew app (which you should be), just include in your index.html:

<link data-trunk rel="css" href="tailwind-yew-builder/output/tailwind.css"/>

Advanced usage

But my source isn't in ../ !

If your source is somewhere else, just tell it through the environment variable. Only it must start with a '.' or a '/' otherwise docker-compose will create an empty drive.

Good

SOURCE_CODE='./my_source' docker-compose up prod

Bad

SOURCE_CODE='my_source' docker-compose up prod

Configuring tailwind

In ./input/ you'll see the tailwind configuration files:

  • tailwind.css - Configure that as shown here
  • tailwind-config.js - Configure that as shown here

If you want you can copy these files to your own source tree, and modify them as needed, then just use the INPUT environment varible to show docker-compose where to look.

For example:

mkdir ../tailwind-css-config
cp input/* ../tailwind-css-config
# Make changes in ../tailwind-css-config as needed
# Now run docker compose
INPUT=../tailwind-css-config docker-compose up watch
# .. or with multiple environment variables:
INPUT=../tailwind-css-config SOURCE_CODE=../my_source docker-compose up watch

Super advanced

Getting a later version of node/npm/tailwind..

If I've been lazy and haven't updated the docker hub image for a while, you can build your own by:

  1. If node.js was updated, in Dockerfile update the wget and tar xf commands to point to the later version
  2. In docker-compose.yaml under image: matiu/tailwind-yew-builder add this line: build: .
  3. docker-compose build

.. then carry on as normal.

Make your own image

You can change the image: matiu/tailwind-yew-builder to your own docker-hub address, build it and run with it.

tailwind-yew-builder's People

Contributors

matiu2 avatar

Watchers

 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.