From 18f4e650bd3a96146b4a5b6eaed1ad268a3a6f8c Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Sun, 15 Oct 2017 13:52:51 -0400 Subject: [PATCH] Support passing config as a path Let's you do tailwind('config.js') instead of tailwind(require('config.js')) when registering Tailwind as a PostCSS plugin. --- docs/webpack.mix.js | 2 +- src/index.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/webpack.mix.js b/docs/webpack.mix.js index 400b04fd6..27333227a 100644 --- a/docs/webpack.mix.js +++ b/docs/webpack.mix.js @@ -15,6 +15,6 @@ const tailwind = require('./../lib/index.js'); mix.less('source/_assets/less/main.less', 'source/css') .options({ postCss: [ - tailwind(require('./tailwind.js')), + tailwind('tailwind.js'), ] }) diff --git a/src/index.js b/src/index.js index d229dd6c4..e0c1f3d56 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,6 @@ import fs from 'fs' +import path from 'path' + import _ from 'lodash' import postcss from 'postcss' import stylefmt from 'stylefmt' @@ -15,6 +17,10 @@ import substituteScreenAtRules from './lib/substituteScreenAtRules' import substituteClassApplyAtRules from './lib/substituteClassApplyAtRules' const plugin = postcss.plugin('tailwind', (options = {}) => { + if (_.isString(options)) { + options = require(path.resolve(options)) + } + const config = mergeConfig(defaultConfig, options) return postcss([