tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Tailwindcss with StencilJS/Web Components

Open ansarizafar opened this issue 8 years ago • 8 comments

I am trying to use tailwind.css from dist folder with StencilJs/Web components https://stenciljs.com/ but hover styles are not working. Is there any solution available?

ansarizafar avatar Jan 08 '18 18:01 ansarizafar

Maybe you are trying to use some of the modules that don't have the hover variant applied. check the docs https://tailwindcss.com/docs/configuration#modules

MatiasVerdier avatar Jan 10 '18 20:01 MatiasVerdier

Here is what I am trying to do.

<button  class="bg-green hover:bg-green-dark text-white font-bold py-2 px-4 rounded-full">Click Me!</button>

ansarizafar avatar Jan 11 '18 05:01 ansarizafar

Can you share a repo that we can clone to try and troubleshoot? I've never heard of StencilJS before so have never used it. If I had to guess, I wonder if it's related to using the : character in our hover class names, especially if StencilJS does some weird compilation or something of the markup.

Try changing it to a different character:

https://tailwindcss.com/docs/configuration#separator

adamwathan avatar Jan 15 '18 14:01 adamwathan

Closing this as it's basically impossible this is a Tailwind issue, but feel free to start a discussion on the discuss repo if you'd like to continue the conversation.

adamwathan avatar Jan 22 '18 15:01 adamwathan

const postcss = require('@stencil/postcss');
const autoprefixer = require('autoprefixer');
const sass = require('@stencil/sass');
const tailwindcss = require('tailwindcss');

exports.config = {
  namespace: 'demo',
  outputTargets:[
    { type: 'dist' },
    { type: 'www' }
  ],
  globalStyle: ['src/app.scss'],
  plugins: [
    sass(),
    postcss({
      plugins: [
        autoprefixer(),
        tailwindcss('./tailwind.js')
      ]
    })
  ]
};

exports.devServer = {
  root: 'www',
  watchGlob: '**/**'
}

I have tailwindcss in the app.scss file, this compiles down to demo.css on build using the postcss plugin @ansarizafar

stellasoft-will avatar Mar 28 '18 14:03 stellasoft-will

@ansarizafar FWIW I got this working using postcss:

import { Config } from '@stencil/core';
import { postcss } from '@stencil/postcss';
import * as autoprefixer from 'autoprefixer';

// https://stenciljs.com/docs/config

export const config: Config = {
  globalStyle: 'src/global/styles.css',  
  plugins: [
    postcss({
      plugins: [
        autoprefixer({
          browsers: ['last 6 versions'],
          cascade: false
        }),
        require('tailwindcss')('./tailwind.js')
      ]
    })
  ]  
};

MattMcFarland avatar Sep 19 '18 16:09 MattMcFarland

@MattMcFarland @stellasoft-will did either of you get this working in typescript? I can't seem to pull in via using require

sunbot avatar Oct 15 '19 00:10 sunbot

@MattMcFarland @stellasoft-will did either of you get this working in typescript? I can't seem to pull in via using require

import tailwindcss from 'tailwindcss';

export const config: Config = {
  globalStyle: 'src/global/styles.css',  
  plugins: [
    postcss({
      plugins: [
        autoprefixer({
          browsers: ['last 6 versions'],
          cascade: false
        }),
        tailwindcss('./tailwind.js')
      ]
    })
  ]  
};

harrysbaraini avatar Dec 13 '19 18:12 harrysbaraini