Skip to content

Instantly share code, notes, and snippets.

@iamgp
Last active March 27, 2021 03:24
Show Gist options
  • Save iamgp/abcb4661f04859639843c2d8e777eee2 to your computer and use it in GitHub Desktop.
Save iamgp/abcb4661f04859639843c2d8e777eee2 to your computer and use it in GitHub Desktop.
var gulp = require('gulp')
var postcss = require('gulp-postcss')
var tw = require('@tailwindcss/jit')
var ap = require('autoprefixer')
var sourcemaps = require('gulp-sourcemaps')
const cleanCSS = require('gulp-clean-css')
var clean = require('gulp-clean')
var nested = require('postcss-nested')
gulp.task('clean-css', function (done) {
return gulp.src('../static/css/*.css', { read: false }).pipe(clean({ force: true }))
})
gulp.task('css', function () {
return gulp
.src('css/**/*.css')
.pipe(sourcemaps.init())
.pipe(postcss([tw('./tailwind.config.js'), nested(), ap()]))
.pipe(cleanCSS())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('../static/css/'))
})
gulp.task('watch', function () {
gulp.watch(['./templates/*.html', './css/*.css'], gulp.series('clean-css', 'css'))
})
gulp.task('default', gulp.series('clean-css', 'css', 'watch'))
@iamgp
Copy link
Author

iamgp commented Mar 27, 2021

Used by just running gulp, not a package.json script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment