Last active
November 8, 2021 10:19
-
-
Save nilsbosman/6d817892104ac8b4b03c9139e9ed1e07 to your computer and use it in GitHub Desktop.
Gulp4 - Tailwind and SCSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load plugins | |
const gulp = require("gulp"); | |
const sass = require('gulp-sass')(require('sass')); | |
const postcss = require("gulp-postcss"); | |
const cssnano = require("gulp-cssnano"); | |
const concat = require("gulp-concat"); | |
const autoprefixer = require("autoprefixer"); | |
// CSS task | |
function styles() { | |
var tailwindcss = require('tailwindcss'); | |
return gulp | |
// start with getting the tailwind.css file | |
.src("./src/css/tailwind.css") | |
// use postcss to compile it. | |
.pipe(postcss([ | |
tailwindcss('./tailwind.config.js') | |
])) | |
// Add new source with your .scss | |
.pipe(gulp.src("./src/css/**/*.scss")) | |
// Compile to css | |
.pipe(sass()) | |
// Concat both files into one styles.css file | |
.pipe(concat("style.css")) | |
// Run postcss again with just autoprefixer so it runs on both files | |
.pipe(postcss([ | |
require('autoprefixer'), | |
])) | |
// Minimise the css file | |
.pipe(cssnano()) | |
// write css file to the filesystem | |
.pipe(gulp.dest("./")) | |
} | |
// define tasks | |
const css = gulp.series(styles); | |
// export tasks | |
exports.css = css; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment