Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exposeConfig to reference resolved config in javascript runtime #69

Merged
merged 8 commits into from
Mar 11, 2020

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
2 participants