Created
June 24, 2018 22:46
-
-
Save EdnilsonRobert/72dcad70a04f83f22faec83aa0f14266 to your computer and use it in GitHub Desktop.
Gulp snippets
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'), | |
browserSync = require('browser-sync'), | |
header = require('gulp-header'), | |
cssnano = require('gulp-cssnano'), | |
package = require('./package.json'); | |
var banner = [ | |
'/*!\n' + | |
' * <%= package.name %>\n' + | |
' * <%= package.title %>\n' + | |
' * <%= package.url %>\n' + | |
' * @author <%= package.author %>\n' + | |
' * @version <%= package.version %>\n' + | |
' * Copyright ' + new Date().getFullYear() + '. <%= package.license %> licensed.\n' + | |
' */', | |
'\n' | |
].join(''); | |
gulp.task('css', function () { | |
return gulp.src('src/scss/style.scss') | |
.pipe(header(banner, { package : package })) | |
.pipe(gulp.dest('app/assets/css')) | |
.pipe(browserSync.reload({stream:true})); | |
}); | |
gulp.task('js',function(){ | |
gulp.src('src/js/scripts.js') | |
.pipe(header(banner, { package : package })) | |
.pipe(gulp.dest('app/assets/js')) | |
.pipe(browserSync.reload({stream:true, once: true})); | |
}); | |
gulp.task('browser-sync', function() { | |
browserSync.init(null, { | |
server: { baseDir: "app" } | |
}); | |
}); | |
gulp.task('bs-reload', function () { | |
browserSync.reload(); | |
}); | |
gulp.task('default', ['css', 'js', 'browser-sync'], function () { | |
gulp.watch("src/scss/**/*.scss", ['css']); | |
gulp.watch("src/js/*.js", ['js']); | |
gulp.watch("app/*.html", ['bs-reload']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment