diff --git a/README.md b/README.md
index 5c165afc..d0a52f36 100755
--- a/README.md
+++ b/README.md
@@ -55,7 +55,8 @@ If you want to set a different path for the configuration file or css file, you
tailwindcss: {
configPath: '~/config/tailwind.config.js',
cssPath: '~/assets/css/tailwind.css',
- purgeCSSInDev: false
+ purgeCSSInDev: false,
+ exposeConfig: false
}
}
```
@@ -83,6 +84,33 @@ You can also use CSS comments to tell purgeCSS to ignore some blocks:
/* purgecss end ignore */
```
+## Referencing in JavaScript
+
+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`:
+
+```js
+// nuxt.config.js
+{
+ tailwindcss: {
+ exposeConfig: true
+ },
+}
+```
+
+Then import where needed from `~tailwind.config`:
+
+```js
+// 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.
+
## Development
1. Clone this repository
diff --git a/example/nuxt.config.js b/example/nuxt.config.js
index 97afa354..1ed63ee9 100644
--- a/example/nuxt.config.js
+++ b/example/nuxt.config.js
@@ -5,6 +5,6 @@ module.exports = {
buildDir: resolve(__dirname, '.nuxt'),
srcDir: __dirname,
modules: [
- { handler: require('../') }
+ [require('../'), { exposeConfig: true }]
]
}
diff --git a/example/pages/index.vue b/example/pages/index.vue
index 446cf7c8..86f84e5a 100644
--- a/example/pages/index.vue
+++ b/example/pages/index.vue
@@ -8,6 +8,14 @@
+
+