Created
February 2, 2018 03:10
-
-
Save tinhochu/1a2df68946f5e2a9889e3c7eaa8a84e2 to your computer and use it in GitHub Desktop.
Implementation of Gulp
This file contains 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
// 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