Last active
December 20, 2020 11:15
-
-
Save anisur3036/3442cee5b87e32a0f4d87a0d54136871 to your computer and use it in GitHub Desktop.
Tailwindcss with Gulp
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
{ | |
"presets": ["env"] | |
} |
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
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var postcss = require('gulp-postcss'); | |
var babel = require('gulp-babel'); | |
var minifyjs = require('gulp-js-minify'); | |
var webserver = require('gulp-webserver'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
//`gulp js` command for js files to compile | |
gulp.task('js', function () { | |
return gulp.src("src/**/*.js") | |
.pipe(sourcemaps.init()) | |
.pipe(babel()) | |
//.pipe(minifyjs()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest("dist")); | |
}); | |
//`gulp style` command for scss file to compile | |
gulp.task('style', function () { | |
var tailwindcss = require('tailwindcss'); | |
return gulp.src('src/**/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(postcss([ | |
tailwindcss('./tailwind.js'), | |
require('autoprefixer'), | |
])) | |
.pipe(gulp.dest('dist/')); | |
}); | |
//watch command for `js` and `style` | |
gulp.task('watch', function() { | |
gulp.watch('src/**/*.js', ['js']); | |
gulp.watch('src/**/*.scss', ['style']); | |
}); | |
//live reload webserver | |
//make sure will have included index file | |
// within dist/build(whatever you call) directory | |
gulp.task('webserver', function() { | |
gulp.src('dist/') | |
.pipe(webserver({ | |
livereload: true, | |
port: 8383, | |
open: true | |
})); | |
}); | |
//default action of `gulp` command | |
gulp.task('default', ['watch', 'webserver']); |
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
{ | |
"private": true, | |
"scripts": { | |
"no-script": "no script" | |
}, | |
"devDependencies": { | |
"autoprefixer": "^8.3.0", | |
"babel-core": "^6.26.0", | |
"babel-preset-env": "^1.6.1", | |
"font-awesome": "^4.7.0", | |
"gulp": "^3.9.1", | |
"gulp-babel": "^7.0.1", | |
"gulp-js-minify": "^0.0.3", | |
"gulp-postcss": "^7.0.1", | |
"gulp-sass": "^4.0.1", | |
"gulp-sourcemaps": "^2.6.4", | |
"gulp-webserver": "^0.9.1", | |
"lodash": "^4.17.5", | |
"tailwindcss": "^0.5.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tailwindcss & Gulp
Tailwindcss with gulp as well as ES6 JS compile down to ES5 using babel and browser live reload package when you save.