Tailwindcss-module: Tailwind CSS styles not globally accessible

Created on 2 Aug 2019  路  4Comments  路  Source: nuxt-community/tailwindcss-module

ISSUE: Tailwind CSS styles not globally accessible

I installed this plugin via the nuxt-create-app CLI.
When trying to use tailwind classes within my .vue files, the styles are not being applied.

The tailwind.css file is located inside: assets/css/tailwind.css
I did not touch the contents:

@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

I read through the docs multiple times, but I can't figure out what's wrong...

Here are my package.json dependencies:

  "dependencies": {
    "cross-env": "^5.2.0",
    "express": "^4.16.4",
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/pwa": "^2.6.0",
    "nuxt": "^2.0.0"
  },
  "devDependencies": {
    "@nuxtjs/tailwindcss": "^1.0.0",
    "nodemon": "^1.18.9"
  }

Here is my nuxt.config.js:

module.exports = {
  mode: 'universal',
  /*
  ** Headers of the page
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      // { rel: 'stylesheet', href: '/css/tailwind.css' },
      // { rel: 'stylesheet', href: '/css/main.css' },
    ]
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
      '@/assets/css/main.css'
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js dev-modules
  */
  devModules: [
    // Doc: https://github.com/nuxt-community/nuxt-tailwindcss
    '@nuxtjs/tailwindcss',
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
  ],
  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
  },
  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
    }
  }
}

Thanks in advance.

Most helpful comment

I found a workaround by adding to the build option of nuxt.config.js:
I think this signals that postcss is not using the tailwindcss plugin by default on install.

The README instructions for this repo don't mention that this is required...

    build: {
        /*
        ** You can extend webpack config here
        */
        extend(config, ctx) {
        },
        postcss: {
            // Add plugin names as key and arguments as value
            // Install them before as dependencies with npm or yarn
            plugins: {
                // Disable a plugin by passing false as value
                'tailwindcss': {}
            },
        }
    }

All 4 comments

I found a workaround by adding to the build option of nuxt.config.js:
I think this signals that postcss is not using the tailwindcss plugin by default on install.

The README instructions for this repo don't mention that this is required...

    build: {
        /*
        ** You can extend webpack config here
        */
        extend(config, ctx) {
        },
        postcss: {
            // Add plugin names as key and arguments as value
            // Install them before as dependencies with npm or yarn
            plugins: {
                // Disable a plugin by passing false as value
                'tailwindcss': {}
            },
        }
    }

This is weird since it's added here: https://github.com/nuxt-community/nuxt-tailwindcss/blob/master/lib/module.js#L39

Are you using Nuxt.js with another framework (express.js, koa, etc?)

@Atinux - I鈥檓 using express.js (as installed by nuxt-create-app CLI)

I鈥檓 away now but will try to dig into this more when I get home later this week

(Thanks for bringing us nuxt!!)

Hi @Govern0r

You can upgrade to v1.1.2, I fixed the issue (and tested on an Express.js example)

(Thank you for kind words 馃槉 )

Was this page helpful?
0 / 5 - 0 ratings