Skip to content

Instantly share code, notes, and snippets.

@tinhochu
Created February 2, 2018 03:10
Show Gist options
  • Save tinhochu/1a2df68946f5e2a9889e3c7eaa8a84e2 to your computer and use it in GitHub Desktop.
Save tinhochu/1a2df68946f5e2a9889e3c7eaa8a84e2 to your computer and use it in GitHub Desktop.
Implementation of Gulp
// Dependencies
'use strict';
var gulp = require('gulp');
var path = require('path');
var livereload = require('gulp-livereload');
var sass = require('gulp-sass');
var maps = require('gulp-sourcemaps');
var cleanCSS = require('gulp-clean-css');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var config = {
publicDir: './'
};
// SASS
gulp.task('sass', function () {
return gulp.src( path.join( config.publicDir, 'assets','scss','style.scss') )
.pipe(maps.init())
.pipe(sass().on('error', sass.logError))
.pipe(postcss([ autoprefixer() ]))
// .pipe(cleanCSS({debug: true}, (details) => {
// console.log(details.name + ': ' + details.stats.originalSize);
// console.log(details.name + ': ' + details.stats.minifiedSize);
// }))
.pipe(maps.write( './' ))
.pipe(gulp.dest('./'));
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('assets/scss/**/*.scss', ['sass']);
// gulp.watch('**/*.php', livereload.reload );
gulp.watch('style.css').on('change', livereload.changed);
});
gulp.task('default', function() {
console.log( "\nNew York Spine - Gulp Command List \n" );
console.log( "----------------------------\n" );
console.log( "gulp watch" );
console.log( "gulp sass" );
console.log( "gulp build \n" );
console.log( "----------------------------\n" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment