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
// Gulp images | |
gulp.task('images', function(){ | |
return gulp.src('img/**/*.+(png|jpg|gif|svg)') | |
// Caching images that ran through imagemin | |
.pipe(cache(imagemin({ | |
interlaced: true | |
}))) | |
.pipe(gulp.dest('img')) | |
}); |
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
gulp.task('compress', function (cb) { | |
pump([ | |
gulp.src('js/*.js'), | |
uglify(), // minifies js in same location | |
gulp.dest('js') | |
], | |
cb | |
); | |
}); |
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
// Convert sass to css | |
gulp.task('sass', function(){ | |
return gulp.src('sass/**/*.scss') // this globs all .scss files found in folder/subfolders | |
// Initializes sourcemaps | |
.pipe(sourcemaps.init()) // this produces a sourcemaps at the bottom of our .css file for browser debugging | |
.pipe(cssnano()) // Added in css Nano | |
.pipe(sass({ | |
errLogToConsole: true // this will log sass console errors in the terminal | |
})) | |
// Writes sourcemaps into the CSS file |
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
{ | |
"name": "app-name", | |
"version": "1.0.0", | |
"description": "npm packages", | |
"main": "gulpfile.js", | |
"dependencies": { | |
"gulp": "^3.9.1" | |
}, | |
"devDependencies": { | |
"browser-sync": "^2.13.0", |
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
// Gulp watch syntax | |
gulp.task('watch', ['browserSync' , 'sass'], function(){ | |
gulp.watch('scss/**/*.scss', ['sass']); // globs .scss files for watching | |
// Reloads the browser whenever HTML or JS files change | |
gulp.watch('*.html', browserSync.reload); // watches all .html files found in the root dir | |
gulp.watch('js/**/*.js', browserSync.reload); // globs .js files for watching | |
console.log('To stop watching type control c'); // this will log a console message that instructs how to stop th gulp task | |
}) |
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
// Browsersync Task | |
gulp.task('browserSync', function() { | |
browserSync.init({ | |
server: { | |
baseDir: '' // were are using the root dir to server browserync | |
}, | |
}) | |
}) |
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
// Convert sass to css | |
gulp.task('sass', function(){ | |
return gulp.src('sass/**/*.scss') // this globs all .scss files found in folder/subfolders | |
// Initializes sourcemaps | |
.pipe(sourcemaps.init()) // this produces a sourcemaps at the bottom of our .css file for browser debugging | |
.pipe(sass({ | |
errLogToConsole: true // this will log sass console errors in the terminal | |
})) | |
// Writes sourcemaps into the CSS file | |
.pipe(sourcemaps.write()) |
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
// Convert sass to css | |
gulp.task('sass', function(){ | |
return gulp.src('sass/**/*.scss') // this globs all .scss files found in folder/subfolders | |
// Initializes sourcemaps | |
.pipe(sourcemaps.init()) // this produces a sourcemaps at the bottom of our .css file for browser debugging | |
.pipe(sass({ | |
errLogToConsole: true // this will log sass console errors in the termninal | |
})) | |
// Writes sourcemaps into the CSS file | |
.pipe(sourcemaps.write()) |
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
// Convert sass to css | |
gulp.task('sass', function(){ | |
return gulp.src('scss/**/*.scss') | |
// Initializes sourcemaps | |
.pipe(sourcemaps.init()) | |
.pipe(sass({ | |
errLogToConsole: true | |
})) | |
// Writes sourcemaps into the CSS file | |
.pipe(sourcemaps.write()) |
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
// gulp | |
var gulp = require('gulp'); | |
// Requires the gulp-sass plugin | |
var sass = require('gulp-sass'); | |
// minify css | |
var cssnano = require('gulp-cssnano'); | |
// implement sourcemaps | |
var sourcemaps = require('gulp-sourcemaps'); | |
// Gulp live reloading | |
var browserSync = require('browser-sync').create(); |
NewerOlder