Standalone Tailwind CSS CLI, installable via pip

Overview

Standalone Tailwind CSS CLI, installable via pip

Use Tailwind CSS without Node.js and install it via pip.

Why

Tailwind CSS is notoriously dependent on Node.js. If you're a Python developer, this dependency may not be welcome in your team, your Docker container, or your inner circle.

The Tailwind CSS team recently announced a new standalone CLI build that gives you the full power of Tailwind CLI in a self-contained executable — no Node.js or npm required.

However, installing such a standalone CLI isn't as easy as running npm install, the installation command for Node.js .

That's why I decided to make it as simple as running pip install command. As a result you can install the standalone * Tailwind CLI* via pip by running the following command:

pip install pytailwindcss

Now you can run tailwindcss in your terminal as:

tailwindcss -i input.css -o output.css --minify

Voila!

Get started

  1. Install tailwindcss via pip by executing the following command:

    pip install pytailwindcss
    
  2. The tailwindcss command should now be available in your terminal. Try to run it:

    tailwindcss
    

    If the installation was successful, you should see the message about binary being downloaded on the first run. When download is complete, you should see the help output for the tailwindcss command. Use tailwindcss to create a new project or work with an existing Tailwind CSS project.

  3. Let's create a new project. Go to the directory where you want to host your Tailwind CSS project and initialize it by running:

    tailwindcss init
    

    This command will create the default tailwind.config.js file.

  4. Start a watcher by running:

    tailwindcss -i input.css -o output.css --watch
    
  5. Compile and minify your CSS for production by running:

    tailwindcss -i input.css -o output.css --minify
    

You got it. Please refer to official Tailwind documentation for more information on using Tailwind CSS and its CLI.

Caveats

It's not all roses, though. Giving up Node.js means you won't be able to install plugins or additional dependencies for your Tailwind CSS setup. At the same time, that might not be a dealbreaker. You can still customize Tailwind CSS via the tailwind.config.js file. And the standalone build also comes with all official Tailwind CSS plugins like @tailwindcss/aspect-ratio, @tailwindcss/forms, @tailwindcss/line-clamp, and @tailwindcss/typography. So in 90% of Tailwind CSS usage cases you should be covered, and the setup is so simplified now.

Here is what the Tailwind CSS team says about going the standalone Tailwind CSS route:

If you’re working on a project where you don’t otherwise need Node.js or npm, the standalone build can be a great choice. If Tailwind was the only reason you had a package.json file, this is probably going to feel like a nicer solution.

Bugs and suggestions

If you have found a bug, please use the issue tracker on GitHub.

https://github.com/timonweb/pytailwindcss/issues

2021 (c) Tim Kamanin - A Full Stack Django and Wagtail Developer

Comments
  • Question: why is ssl used in a 'unverified' mode ?

    Question: why is ssl used in a 'unverified' mode ?

    The code that fetches the tailwindcss binaries from github looks like this:

        # Ensures SSL certificate verification doesn't fail
        ssl._create_default_https_context = ssl._create_unverified_context
        urllib.request.urlretrieve(url, str(dest_filename))
    

    This is called by the main() function.

    This means anyone using pytailwindcss after installation will try and download binaries from github.com, but without making sure the binary files come from the correct host, which can lead to all kinds of attack (and defeats the purpose of using SSL in the first place).

    If they are legitimate cases for the SSL verification to be skipped, I think the code above can be kept, but only if something like an --insecure option is passed. By the way, this is what both curl and wget do.

    Feel free to tell me if I've missed something or if you need more information. I can also work on a patch if you like.

    opened by dmerejkowsky 7
  • KeyError: 'AMD64'

    KeyError: 'AMD64'

    When I call tailwindcss in the command prompt I get this error:

     File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\Scripts\tailwindcss.exe\__main__.py", line 7, in <module>
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\__main__.py", line 9, in main
        completed_process = pytailwindcss.run(
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\__init__.py", line 45, in run
        install(version, bin_path)
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\__init__.py", line 69, in install
        return install_binary(version, ensure_is_pathlib_path(bin_path))
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\installation.py", line 27, in install_binary
        binary_name = f"tailwindcss-{detect_target()}"
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\installation.py", line 58, in detect_target
        return format_target(os_name=platform.system(), arch=platform.machine())
      File "C:\Users\ianba\AppData\Local\Programs\Python\Python39\lib\site-packages\pytailwindcss\installation.py", line 70, in format_target
        return {
    KeyError: 'AMD64' 
    
    opened by IanTerzo 5
  • The `content` key is missing or empty.

    The `content` key is missing or empty.

    Hi! After installing the package I run the command to generate the output css file but I get the following error:

    (venv) [guillermo@arch guarde]$ tailwindcss -i input.css -o style.css --minify
    
    warn - The `content` key is missing or empty. Please populate the content key as Tailwind generates utilities on-demand based on the files that use them. For more information see the documentation: https://tailwindcss.com/docs/content-configuration
    
    Done in 233ms.
    

    I'm guessing I must edit the content key in the tailwind.config.js file but I can't seem to find it inside my venv. Sorry if it's a silly issue... Cheers

    opened by guillermohs9 2
  • CSS not showing, getting warnings about missing 'content' in configuration

    CSS not showing, getting warnings about missing 'content' in configuration

    after running: tailwindcss -i style.css -o output.css --watch

    i get an warning about: warn - The content option in your Tailwind CSS configuration is missing or empty. warn - Configure your content sources or your generated CSS will be missing styles. warn - https://tailwindcss.com/docs/content-configuration

    i though thar my content paths are wrong. and after trying every possible combination still get that warning and the css isnt working.

    i found that that was an issue on: https://tagmerge.com/issue/tailwindlabs/tailwindcss/7210

    but i don't know is it relevant.

    Can you maybe chek it out? thanks.

    opened by arcii-py 1
  • Binary not found

    Binary not found

    I configured Flask-Assets to create the output css using Bundle. However in production the binary tailwindcss is not found. This is because after pip install pytailwindcss the binary is not yet created. Locally I can run tailwindcss to create the binary, however this is not possible when deploying to production. I can only list pytailwindcss in requirements.txt but this doesn't create the required binary. Can you make it so that pip install pytailwindcss also creates the binary, so that step 2 of the Get Started is obsolete?

    opened by kapitalisman 0
Owner
Tim Kamanin
Proactive full stack developer
Tim Kamanin
Sink is a CLI tool that allows users to synchronize their local folders to their Google Drives. It is similar to the Git CLI and allows fast and reliable syncs with the drive.

Sink is a CLI synchronisation tool that enables a user to synchronise local system files and folders with their Google Drives. It follows a git C

Yash Thakre 16 May 29, 2022
flora-dev-cli (fd-cli) is command line interface software to interact with flora blockchain.

Install git clone https://github.com/Flora-Network/fd-cli.git cd fd-cli python3 -m venv venv source venv/bin/activate pip install -e . --extra-index-u

null 14 Sep 11, 2022
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
Python-Stock-Info-CLI: Get stock info through CLI by passing stock ticker.

Python-Stock-Info-CLI Get stock info through CLI by passing stock ticker. Installation Use the following command to install the required modules at on

Ayush Soni 1 Nov 5, 2021
A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool

Privateer A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool How

Shreyash Chavan 2 Apr 4, 2022
Yts-cli-streamer - A CLI movie streaming client which works on yts.mx API written in python

YTSP It is a CLI movie streaming client which works on yts.mx API written in pyt

null 1 Feb 5, 2022
[WIP]An ani-cli like cli tool for movies and webseries

mov-cli A cli to browse and watch movies. Installation This project is a work in progress. However, you can try it out python git clone https://github

null 166 Dec 30, 2022
Customisable pharmacokinetic model accessible via bash CLI allowing for variable dose calculations as well as intravenous and subcutaneous administration calculations

Pharmacokinetic Modelling Group Project A PharmacoKinetic (PK) modelling function for analysis of injected solute dynamics over time, developed by Gro

null 1 Oct 24, 2021
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
Python CLI vm manager for remote access of docker images via noVNC

vmman is a tool to quickly boot and view docker-based VMs running on a linux server through noVNC without ssh tunneling on another network.

UCSD Engineers for Exploration 1 Nov 29, 2021
Dead simple CLI tool to try Python packages - It's never been easier! :package:

try - It's never been easier to try Python packages try is an easy-to-use cli tool to try out Python packages. Features Install specific package versi

Timo Furrer 659 Dec 28, 2022
CLI for SQLite Databases with auto-completion and syntax highlighting

litecli Docs A command-line client for SQLite databases that has auto-completion and syntax highlighting. Installation If you already know how to inst

dbcli 1.8k Dec 31, 2022
Postgres CLI with autocompletion and syntax highlighting

A REPL for Postgres This is a postgres client that does auto-completion and syntax highlighting. Home Page: http://pgcli.com MySQL Equivalent: http://

dbcli 10.8k Jan 2, 2023
A supercharged AWS command line interface (CLI).

SAWS Motivation AWS CLI Although the AWS CLI is a great resource to manage your AWS-powered services, it's tough to remember usage of: 70+ top-level c

Donne Martin 5.1k Jan 5, 2023
CLI program that allows you to change your Alacritty config with one command without editing the config file.

Pycritty Change your alacritty config on the fly! Installation: pip install pycritty By default, only the program itself will be installed, but you ca

Antonio Sarosi 184 Jan 7, 2023
QueraToCSV is a simple python CLI project to convert the Quera results file into CSV files.

Quera is an Iranian Learning management system (LMS) that has an online judge for programming languages. Some Iranian universities use it to automate the evaluation of programming assignments.

Amirmahdi Namjoo 16 Nov 11, 2022
Simple CLI tool to track your cryptocurrency portfolio in real time.

Simple tool to track your crypto portfolio in realtime. It can be used to track any coin on the BNB network, even obscure coins that are not listed or trackable by major portfolio tracking applications.

Trevor White 69 Oct 24, 2022