Created
March 29, 2016 22:16
-
-
Save ohmyhusky/7a10b496907d194b8c9d91f6f6d2f626 to your computer and use it in GitHub Desktop.
gulp start point
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
var gulp = require ( 'gulp' ); | |
var minifyCSS = require ( 'gulp-minify-css' ); | |
var uglify = require ( 'gulp-uglify' ); | |
var clean = require ( 'gulp-clean' ); | |
var rename = require ( 'gulp-rename' ); | |
var jshint = require ( 'gulp-jshint' ); | |
var plumber = require ( 'gulp-plumber' ); | |
var sass = require ( 'gulp-sass' ); | |
var autoprefixer = require ( 'gulp-autoprefixer' ); | |
var concat = require ( 'gulp-concat' ); | |
var nodemon = require ( 'gulp-nodemon' ); | |
// npm i --save-dev gulp gulp-minify-css gulp-uglify gulp-clean gulp-rename gulp-jshint gulp-plumber gulp-sass gulp-autoprefixer gulp-concat gulp-nodemon | |
/*** | |
* output file into the same directory | |
* gulp.src ( '...' ) | |
* .pipe ( gulp.dest ( ( file )=> | |
* file.base; | |
* ) ); | |
*/ | |
// gulp.task ( 'concat', () => | |
// gulp.src ( '....js' ) | |
// .pipe ( concat ( 'main.js' ) ) | |
// .pipe ( gulp.dest ( 'assets/' ) ) | |
// ); | |
gulp.task ( 'clean', () => | |
gulp.src ( 'assets/*', { read : false } ) | |
.pipe ( clean () ) | |
); | |
gulp.task ( 'style', () => | |
// gulp.src ( 'css/main.scss' ) | |
// .pipe ( sass ( { style : 'expanded' } ) ) | |
gulp | |
.src ( 'css/style.css' ) | |
.pipe ( autoprefixer ( { | |
browsers : [ 'last 2 versions' ], | |
cascade : false | |
} ) ) | |
.pipe ( gulp.dest ( 'assets' ) ) | |
.pipe ( minifyCSS () ) | |
.pipe ( rename ( { suffix : '.min' } ) ) | |
.pipe ( gulp.dest ( 'assets' ) ) | |
); | |
gulp.task ( 'script', () => | |
gulp | |
.src ( 'js/script.js' ) | |
.pipe ( plumber () ) | |
.pipe ( jshint () ) | |
.pipe ( gulp.dest ( 'assets' ) ) | |
.pipe ( uglify () ) | |
.pipe ( rename ( { suffix : '.min' } ) ) | |
.pipe ( gulp.dest ( 'assets' ) ) | |
); | |
gulp.task ( 'watch', () => { | |
gulp.watch ( 'css/*', [ 'style' ] ).on ( 'change', ( event ) => { | |
console.log ( 'File ' + event.path + ' was ' + event.type + ', running tasks...' ); | |
console.log ( 'gulp watch : css reloaded' ); | |
} ); | |
gulp.watch ( 'js/*', [ 'script' ] ).on ( 'change', ( event ) => { | |
console.log ( 'File ' + event.path + ' was ' + event.type + ', running tasks...' ); | |
console.log ( 'gulp watch : js reloaded' ); | |
} ); | |
} ); | |
gulp.task ( 'run', [ 'clean', 'script', 'style' ], () => { | |
nodemon ( { | |
script : 'server.js', | |
env : { | |
'NODE_ENV' : 'development' | |
} | |
} ) | |
} ); | |
gulp.task ( 'default', [ 'run', 'watch' ], () => { | |
return console.log ( 'default' ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment