Last active
October 19, 2018 13:26
-
-
Save bekatom/5acbd1aedf633ebf1336 to your computer and use it in GitHub Desktop.
Minify javascript and Css 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
| var gulp = require('gulp'); | |
| var uglify = require('gulp-uglify'); | |
| var minifyCss = require('gulp-minify-css'); | |
| gulp.task('js', function() { | |
| return gulp.src('public/javascripts/*.js') | |
| .pipe(uglify()) | |
| .pipe(gulp.dest('public/javascripts/min')); | |
| }); | |
| gulp.task('css', function() { | |
| return gulp.src('public/stylesheets/*.css') | |
| //processImport: false if you are using @import in css | |
| .pipe(minifyCss({processImport: false})) | |
| .pipe(gulp.dest('public/stylesheets/min')); | |
| }); | |
| gulp.task('watch-js', function() { | |
| gulp.watch('public/javascripts/*.js', ['js']); | |
| }); | |
| gulp.task('watch-css', function() { | |
| gulp.watch('public/stylesheets/*.css', ['css']); | |
| }); | |
| gulp.task('default', ['js', 'watch-js','css','watch-css']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment