JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11092
  • Score
    100M100P100Q197121F
  • License Apache-2.0

Package Exports

  • sd-tailwindcss-transformer
  • sd-tailwindcss-transformer/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sd-tailwindcss-transformer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sd-tailwindcss-transformer

Release Test
This is a plugin to generate the config of Tailwind CSS using Style Dictionary.

Install

$ npm install sd-tailwindcss-transformer
# or with yarn
$ yarn add sd-tailwindcss-transformer

Usage

Creating configuration file

Use when you don't need to customize the configuration file much.
If you need more detailed customization, please see Creating each theme file.
example:

const StyleDictionaryModule = require('style-dictionary')
const { makeSdTailwindConfig } = require('sd-tailwindcss-transformer')

const StyleDictionary = StyleDictionaryModule.extend(
  makeSdTailwindConfig({ type: 'all' })
)

StyleDictionary.buildAllPlatforms()

The following files will be generated when the build is executed:

// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  mode: "jit",
  content: ["./src/**/*.{ts,tsx}"],
  darkMode: "class",
  theme: {
    extend: {
      colors: {
        base: {
          gray: "#111111",
          red: "#FF0000",
          ...
        }
      },
      fontSize: {
        small: "0.75rem",
        medium: "1rem",
        ...
      }
    },
  }
}

Creating each theme file

Create an object for each theme, assuming that various customizations will be made in the configuration file.
Import and use the created files in tailwind.config.js.
example:

const StyleDictionaryModule = require('style-dictionary')
const { makeSdTailwindConfig } = require('sd-tailwindcss-transformer')

const types = ['colors', 'fontSize']

types.map((type) => {
  const StyleDictionary = StyleDictionaryModule.extend(
    makeSdTailwindConfig({ type })
  )

  StyleDictionary.buildAllPlatforms()
})

The following files will be generated when the build is executed:

/// colors.tailwind.js
module.exports = {
  base: {
    gray: "#111111",
    red: "#FF0000",
    ...
  }
}
/// fontSize.tailwind.js
module.exports = {
  small: "0.75rem",
  medium: "1rem",
  ...
}

Please see Example for details.

Options

Attribute Description Type
type Set the name of each theme (colors, fontSize, etc.) for 'all' or tailwind. 'all' or string
source source attribute of style-dictionary.
Default value: ['tokens/**/*.json']
Array of strings
transforms platform.transforms attribute of style-dictionary.
Default value: ['attribute/cti','name/cti/kebab']
Array of strings
buildPath platform.buildPath attribute of style-dictionary.
Default value: 'build/web/'
string
tailwind.content Content attribute of tailwind css. Set if necessary when 'all' is set in type.
Default value: ['./src/**/*.{ts,tsx}']
Array of strings
tailwind.darkMode Dark Mode attribute of tailwind css. Set if necessary when 'all' is set in type.
Default value: 'class'
'media' 'class'

License

Apache 2.0