Some styles are not applied in production mode with "srcDir" nuxt.config.js option.
See original GitHub issueVersion
@nuxtjs/tailwindcss: 2.0.0 nuxt: 2.12.0
What is actually happening?
Hi, this is Peter.
I tried to install this module, worked perfectly in dev mode, but some tailwind css has not been applied when I executed nuxt build
and nuxt start
.
Without “srcDir” option in production mode
As you can see, tailwind’s class styles .bg-black
and .container
are applied.
With “srcDir” options in production mode
The problem is that .container
style is applied, .bg-black
is not applied with all scripts are in srcDir
.
I tried to install all dependencies by using both npm
and yarn
, but got same result.
Please let me know If my configuration is wrong! Thank you.
[10, August] @nuxtjs/tailwindcss has been updated from 2.x to 3.0, still got same issue.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10
Top Results From Across the Web
Some styles are not applied in production mode with "srcDir ...
Hi, this is Peter. I tried to install this module, worked perfectly in dev mode, but some tailwind css has not been applied...
Read more >nuxt styles won't be applied in production mode - Stack Overflow
i solved my issue by adding this paragraph to nuxt.config.js build configuration. that's actually what i figured out about it. i've had ...
Read more >Nuxt configuration file
This option lets you define the development or production mode of Nuxt (important when you use Nuxt programmatically). nuxt.config.js
Read more >The build Property - Nuxt
Customize Babel configuration for JavaScript and Vue files. .babelrc is ignored by default. Type: Object; See babel-loader options and babel options; Default: { ......
Read more >The srcDir Property - Nuxt
The srcDir property. Define the source directory of your Nuxt application. Type: String; Default: rootDir value. If a relative path is specified it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @misikoff
First, you need to move
tailwind.config.js
in thesrc/
directory OR to defineconfigPath: '~~/tailwind.config.js'
(~~
is the alias forrootDir
, see https://nuxtjs.org/guides/directory-structure/assets#aliases).Then you will see a message saying:
I actually merged #170 and released the v3.1.0 supporting the
srcDir
as well as TypeScript, so you can update your dependency and it’s good to go 🚀@peterkimzz I am currently running into the same problem.
I found that the problem is caused by PurgeCSS, which is a tool that strips all unused CSS from your application build. This way whatever Tailwind utitilies you don’t use are also not shipped to the user, resulting in smaller payloads and thereby better performance. PurgeCSS is only enabled in production mode, which is why your development environment works just fine but the output of both the
build
andgenerate
scripts don’t.In my project I write my pages and components in
.vue
files. For the<style>
blocks with@apply
directives everything seems to work just fine. However the classes used directly in the<template>
tag are somehow not found and therefore purged. We need to check both the<template>
block as well as the<style>
block to preserve the classes used.