Importing in tailwind config elsewhere for variable access #50
Comments
Can you share what you're trying? I would be surprised if you couldn't just do this in a single file .vue component or wherever you need it:
|
Tried that, didn't work in NuxtJS. Did it work on Vue?
Correct me if I'm wrong, I think EDIT: Found this PR that shows how to get the default configurations. But does not say how to get our own configs. |
@pxwee5 did you figure this out? I just got this with vuejs and I was able to do both |
This issue happens because you are mixing |
I'm running into this same issue and wondering if anyone has a fix/workaround? I started like @CalebKester and I'd really like to get this working w/ my own tailwind config. Thanks in advance! |
@jeissler - I'm pretty sure that what @adamwathan stated earlier works. I gave it a quick go again in a current project I have going and it worked. in my app.js file I have the following:
Then I get this in my console: |
@dolbex Thanks for your quick reply! I'm using the latest vue-cli for my project and I'm seeing exactly the same error as @pxwee5 when attempting to use require as shown. It seemed as if @CalebKester had the same behavior in vue (how I found this thread)?
I believe it is to do w/ @Grsmto's comment about mixing import/module.export. I can however get the default config to work using:
Any ideas are appreciated because I really need this to work! |
@jeissler - no problem - sorry I couldn't respond to this sooner. My guess is this has to do with the difference in webpack configurations. I'm certainly not a master at that stuff. Usually, I just mess around until I get what I want but I can tell you some of the environmental setup I am running on this current project where I did my test. Maybe that'll help (maybe I'm totally off base here) For .babelrc I have the following config:
For my package.json I have the following babel devDependencies:
Laravel Mix (this version at least) has a dependency of Maybe that can highlight some differences between our two environments |
@dolbex I can't thank you enough for this. I was about to ask what version of webpack you where on! Since I'm using the cli v3 I had to hunt around the plugins to see the diffs in our config, but it turns out they're very similar—exception being my webpack is 4.25.1. Setting up a new cli project to try and narrow it down to my use of typescript + class based components I found the problem in my case was actually completely unrelated to any of that. I'm a noob to tailwind and in my tailwind.js I had |
Does anyone know how you could insert the tailwind config variables into a SCSS file? Like, inject and parse the objects into the top of the main SCSS entry file before compilation so you can use them in your SCSS. |
@jeissler - no problem glad you got it sorted out. @Dobby89 I don't know how that is possible either. @adamwathan - maybe you should shed some light? |
@Dobby89 @dolbex |
I am having an error like below when I try to import the Tailwind config in a Vue component using require.
After few checks, I've noticed that it is because of the custom plugins that are being added in the plugins section as follows:
and the plugin itself (just a simple one to add background with two colors)
if I remove the plugin from the tailwind config, then requiring the tailwind config from Ve component works fine. Hoping this will help others. |
Hey, Loving TW so far!
I'm working on a Vue project and I would like to import the tailwind config so that I can access the colors property and pull out a value so I can have a central place for those variables.
This is probably a newbie question but what's the best way to import that default export and access those variables? The way I'm doing it it's bitching about dependencies. Thanks for the work and help!
The text was updated successfully, but these errors were encountered: