-
Notifications
You must be signed in to change notification settings - Fork 680
Blendid + Tailwind (postcss alt task) #550
Comments
I have tailwind running on a couple of projects with Blendid. You just need to adjust the stylesheet property in the task-config.js file and take advantage of the alternateTask method. Below is an example from a project I am currently working on. You'll need to adapt the paths to your setup. [note: @olets adjusted the markdown formatting of this code. no changes were introduced] stylesheets: {
extensions: ['scss'],
alternateTask: function (gulp, PATH_CONFIG, TASK_CONFIG) {
// PostCSS task instead of Sass
const browserSync = require('browser-sync');
const postcss = require('gulp-postcss');
const tailwindcss = require('tailwindcss');
const sass = require('gulp-sass');
const gulpif = require('gulp-if');
const sourcemaps = require('gulp-sourcemaps');
const colorFunction = require('postcss-color-function');
return function () {
const plugins = [
tailwindcss('./../../tailwind.js'),
require('postcss-color-function'),
require('autoprefixer')
// require('postcss-fontpath')
];
const paths = {
src: path.resolve(process.env.INIT_CWD, PATH_CONFIG.src, PATH_CONFIG.stylesheets.src, '**/*.scss'),
dest: path.resolve(process.env.INIT_CWD, PATH_CONFIG.dest, PATH_CONFIG.stylesheets.dest)
};
return gulp
.src(paths.src)
.pipe(gulpif(!global.production, sourcemaps.init()))
.pipe(sass())
.pipe(postcss(plugins))
.pipe(gulpif(!global.production, sourcemaps.write()))
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream());
};
}
}, |
An important addition that took me a few rounds of debugging to figure out: you need to also require 'path' in the constants declarations at the top as follows:
|
Adding my
|
Any help adding PurgeCSS to remove unused tailwind styles? |
@estebancastro check out A Better Approach for Using Purgecss with Tailwind from Viget! |
Has anyone configured Blendid to work with Tailwind? Would love to see some examples if so.
Per this thread, it'd be so helpful to get some pre-baked alternative tasks like PostCSS.
Thanks
The text was updated successfully, but these errors were encountered: