tailwindlabs / discuss

A place to ask questions, get help, or share what you've built with Tailwind CSS.
MIT License
171 stars 9 forks source link

Reusing configuration #90

Open klickreflex opened 6 years ago

klickreflex commented 6 years ago

Hey there,

I'm trying to re-use the configuration I stored in one project's tailwind.js from within another. Is this possible?

Say I'm having to projects, where the slave should inherit all config from the master:

master/tailwind.js
slave/tailwind.js

How would I do that? I had no luck just importing the master's config file from the slave's: import config from '../master/tailwind.js'

--> SyntaxError: Unexpected token import

PS: totally in love with Tailwind, thank you so much for your fantastic work :)

adamwathan commented 6 years ago

Depending on your environment you might just have to use a boring old require there instead, have you tried that?

var config = require('../master/tailwind.js')

klickreflex commented 6 years ago

Thanks, but If I do that and, for example, change a color in master the slave stays with the default values :(

Also I'd like to be able to override individual config values in slave. Say I'm having a master theme that defines a basic look. In slave 1 want to change the font stack, in slave 2 I need to adapt colors etc.

Update

Yay, it does works like that :) I just had an error in my modules.exports. Hooray, that's really great for Child-Themes :)

For future reference:

const config = require('../master/tailwind');

config.colors['grey'] = '#eee'
config.screens['md'] = '500px'

module.exports = config;
dsazup commented 6 years ago

hey @klickreflex, how did you get this to work ? 🤔

Not sure what am I doing wrong, using laravel + tailwind and it looks like if I use tailwind post css plugin twice in webpack.mix.js, it will use the default (or maybe the one used first) config.

klickreflex commented 6 years ago

Hi @mirago,

I'm using tailwind with Gulp and don't really know anything about Laravel. Sorry not to be of any help here.

dsazup commented 6 years ago

No worries, thanks for response though. For anyone interested, my issue is related to laravel mix rather than tailwind itself.