npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

esm-mailwind

v1.0.2

Published

Use Tailwind CSS to design HTML emails. ESM version.

Downloads

6

Readme

Mailwind

Use Tailwind CSS to design HTML emails.

This project is based of 'mailwind' developped by @soheilpro. However, I had a few problems when using mailwind. So I made this esm-friendly version to satisfy my needs.

Difference with solheilpro/mailwind

| Features | esm-mailwind | mailwind | | ----------- | ----------- | ----------- | | Parse tailwind html | ✔️ | ✔️ | | Parse tailwind config | ✔️ | ✔️ | | Convert 'rem' to 'px' | ✔️ | ❌ | | Resolves CSS variables | ✔️ | ❌ | | ESM-friendly | ✔️ | ❌ |

Install

npm install esm-mailwind --save-dev

or if you want to install globally:

npm install esm-mailwind -g

Usage

Design your HTML email using the Tailwind utility classes like you normally would for the web.

Then run the following command to generate the corresponding CSS file:

mailwind --input-html email.html --output-css style.css

Or run this command to generate an inlined HTML file:

mailwind --input-html email.html --output-html email-inlined.html

If you want to specify your own base pixels per 1rem:

mailwind --input-html email.html --output-html email-inlined.html --base-px 16

Options

--input-css

The path to your base CSS file. Use this if you need to write custom CSS. Defaults to style.css.

--input-html

The path to your HTML email file.

--output-css (optional)

The path to the CSS file that will be generated.

--output-html

The path to the inlined HTML file that will be generated.

--tailwind-config (optional)

The path to your custom Tailwind configuration file. Defaults to tailwind.config.js.

--base-px (optional)

The base number of pixels per 1rem; default = 16.

Note

In the provided default config file, all the units are changed to pixel which is probably what you want for HTML emails.

Example

Given an email.html file with this content:

<html>
  <body>
    <p class="font-bold text-lg">Welcome</p>
  </body>
</html>

running this command:

mailwind \
  --input-html email.html \
  --output-css style.css \
  --output-html email-inlined.html

will generate the following CSS and inlined HTML files:

.text-lg {
  font-size: 18px
}

.font-bold {
  font-weight: 700
}
<html>
  <body>
    <p class="font-bold text-lg" style="font-size: 18px; font-weight: 700;">Welcome</p>
  </body>
</html>

Version History

  • 1.0.0
    • ESM support
    • Parse CSS variables
    • Add rem to px conversion

Version history before Fork of mailwind:

  • 2.2
    • Tailwind CSS is now a peer dependency so you can npm install newer versions if you need to (Thanks Songkeys)
  • 2.1
    • Colors are now generated without using CSS variables
    • Upgrade to Tailwind CSS v3.2
  • 2.0
    • New design
    • Upgrade to Tailwind CSS v3
  • 1.0
    • Initial release

Author

Benjy Larcher

  • https://benjylarcher.com
  • http://twitter.com/benjythebee
  • http://github.com/benjythebee

With credit due to: