Skip to content

Conversation

@pi0
Copy link
Contributor

@pi0 pi0 commented Mar 10, 2020

closes #62


It can often be useful to reference tailwind configuration values in runtime. For example to access some of your theme values when dynamically applying inline styles in a component.

If you need resolved tailwind config in runtime, you can enable exposeConfig option in nuxt.config:

// nuxt.config.js
{
  tailwindcss: {
    exposeConfig: true
  },
}

Then import where needed from ~tailwind.config:

// Import fully resolved config
import tailwindConfig from '~tailwind.config'

 // Import only part which is required to allow tree-shaking
import { theme } from '~tailwind.config'

NOTE: Please be aware this adds ~19.5KB (~3.5KB) to the client bundle size.

image

@pi0 pi0 requested a review from atinux March 10, 2020 17:20
@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #69 into master will increase coverage by 0.43%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
+ Coverage   97.43%   97.87%   +0.43%     
==========================================
  Files           3        3              
  Lines          39       47       +8     
  Branches        8        9       +1     
==========================================
+ Hits           38       46       +8     
  Misses          1        1
Impacted Files Coverage Δ
lib/module.js 96.77% <100%> (+1.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f711f42...d221209. Read the comment docs.

@pi0 pi0 changed the title feat: exposeConfig to access resolved config in runtime feat: exposeConfig to access resolved config in runtime Mar 10, 2020
@pi0 pi0 changed the title feat: exposeConfig to access resolved config in runtime feat: exposeConfig to reference resolved config in javascript runtime Mar 10, 2020
@atinux atinux merged commit 3a61eed into master Mar 11, 2020
@delete-merged-branch delete-merged-branch bot deleted the feat/expose-config branch March 11, 2020 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: expose resolved Tailwind config within app

3 participants