Skip to content

Instantly share code, notes, and snippets.

@andykillen
Created August 21, 2016 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andykillen/f488df53124e979361fb8e739dd2bed6 to your computer and use it in GitHub Desktop.
Save andykillen/f488df53124e979361fb8e739dd2bed6 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var concat = require('gulp-concat');
// var minifyCSS = require('gulp-minify-css');
var minify = require("gulp-minify");
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
gulp.task('styles', function() {
gulp.src('scss/screen.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename('stylesheet.css'))
.pipe(gulp.dest('./css/'));
});
gulp.task('combine_js', function() {
return gulp.src(['./js/tools.js', './js/ajax.js', './js/script.js', './js/menu.js'])
.pipe(concat('scripts.combined.js'))
.pipe(gulp.dest('./js'));
});
gulp.task('minify_css', function(){
return gulp.src('./css/stylesheet.css')
.pipe(autoprefixer({
browsers: ['last 3 versions'],
cascade: false
}))
.pipe(rename('style.min.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('./css/'));
});
gulp.task('minify-js', function () {
return gulp.src('./js/scripts.combined.js') // path to your files
.pipe(rename('scripts.min.js'))
.pipe(minify({
ext:{
src:'-debug.js',
min:'.js'
},
exclude: ['tasks']}))
.pipe(gulp.dest('js/'));
});
gulp.task('default', function() {
gulp.watch('./js/tools.js', ['combine_js' ]);
gulp.watch('./js/menu.js', ['combine_js' ]);
gulp.watch('./js/script.js', ['combine_js' ]);
gulp.watch('./js/ajax.js', ['combine_js' ]);
gulp.watch('./js/scripts.combined.js', [ 'minify-js']);
gulp.watch('./css/stylesheet.css', ['minify_css']);
gulp.watch('./scss/**/*.scss',['styles']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment