Coder Social home page Coder Social logo

eleventy-plugin-tailwind's Introduction

Eleventy Plugin - Tailwind

Install:

npm install @jamshop/eleventy-plugin-tailwind autoprefixer postcss tailwindcss

Usage

In you main config .eleventy.js:

const pluginTailwind = require("@jamshop/eleventy-plugin-tailwind");

module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(pluginTailwind, {
    entry: "src/tailwind.css",
    output: "_site/css/tailwind.css",
    inputDir: "site"
  });
  // and the rest of your config
};

This will compile src/tailwind.css to _site/css/tailwind.css.

In src/tailwind.css you can add Tailwind directives such as:

@tailwind base;
@tailwind components;
@tailwind utilities;

The inputDir option is required and should match your 11ty input directory. This is used to create a default Tailwind config that will correctly purge unused classnames from tailwindCSS.

The default config can be extended by the inclusion of a tailwind.config.js file in the root directoy of your project or by passing a tailwindConfig option to the plugin. These option will be merged with the default configuration.

Tailwind v2 will only purge when NODE_ENV is set to production: https://tailwindcss.com/docs/optimizing-for-production. This is not a requirement for V3.

eleventy-plugin-tailwind's People

Contributors

madebymike avatar

Stargazers

Sean P. Myrick V19.1.7.2 avatar Andrejs Agejevs avatar uvacoder avatar Roman Yusipov avatar  avatar Col avatar Mathis Barré avatar Iain Bean avatar

Watchers

James Cloos avatar Col avatar Sean P. Myrick V19.1.7.2 avatar

eleventy-plugin-tailwind's Issues

production is purging all

Hi,

That's a fantastic idea to put tailwind integration into a plugin, thank you so much !
I tried to use your plugin instead of building css through post-css-cli

It works locally for me, but when in production the purge doesn't include styles located in templates in my input directory (njk files). So in production, css is too much purged.

In the plugin config I set inputDir the same as the dir.input of eleventy (named src). Is it correct ?

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.