Created
September 2, 2016 09:45
-
-
Save dandaka/3e342158763f9ccbd23305eecfd0b69c to your computer and use it in GitHub Desktop.
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 jade = require('gulp-jade'); | |
var sass = require('gulp-sass'); | |
var watch = require('gulp-watch'); | |
var connect = require('gulp-connect'); | |
var favicons = require('gulp-favicons'); | |
var ga = require('gulp-ga'); | |
var postcss = require('gulp-postcss'); | |
var autoprefixer = require('autoprefixer'); | |
var responsive = require('gulp-responsive'); | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var print = require('gulp-print'); | |
var config = { | |
bowerDir: './bower_components' , | |
gaId: 'UA-57471041-1', | |
url: 'accuraten.com', | |
appName: 'Accuraten bureau', | |
appDescription: 'Accuraten bureau', | |
developerName: 'Vlad Rafeev' | |
} | |
gulp.task('default', ['jade', 'sass', 'js', 'connect', 'watch']); | |
gulp.task('jade', function() { | |
gulp.src('./src/jade/*.jade') | |
.pipe(jade()) | |
.pipe(ga({url: 'auto', uid: config.gaId, tag: 'body',sendPageView: true, minify: false, anonymizeIp: false})) | |
.pipe(gulp.dest('./public/')); | |
}); | |
gulp.task('sass', function () { | |
gulp.src('./src/sass/style.scss') | |
.pipe(sass({ | |
includePaths: [ | |
config.bowerDir + '/bootstrap/scss', | |
config.bowerDir + '/font-awesome/scss' | |
], | |
outputStyle: 'compressed' | |
}) | |
.on('error', sass.logError)) | |
.pipe(postcss([ autoprefixer({ browsers: ['last 2 versions'] }) ])) | |
.pipe(gulp.dest('./public/css')); | |
}); | |
gulp.task('connect', function() { | |
connect.server({ | |
root: 'public', | |
livereload: true | |
}); | |
}); | |
gulp.task('watch', function () { | |
gulp.watch(['./src/jade/**/*.jade'], ['jade']); | |
gulp.watch(['./src/sass/**/*.scss'], ['sass']); | |
gulp.watch(['./src/js/**/*.js'], ['js']); | |
watch(['./public/**/*.html', './public/**/*.css', './public/**/*.js']).pipe(connect.reload()); | |
}); | |
gulp.task('js', function () { | |
return gulp.src([ | |
'./node_modules/fontfaceobserver/fontfaceobserver.js', | |
'./bower_components/jquery/dist/jquery.min.js', | |
'./bower_components/bootstrap/js/dist/util.js', | |
'./bower_components/bootstrap/js/dist/collapse.js', | |
'./bower_components/picturefill/dist/picturefill.js', | |
'./src/js/modernizr.js', | |
'./src/js/js.js' | |
]) | |
.pipe(concat({ path: 'js.js'})) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./public/js')); | |
}); | |
gulp.task('icons', function() { | |
return gulp.src(config.bowerDir + '/font-awesome/fonts/**.*') | |
.pipe(gulp.dest('./public/fonts')); | |
}); | |
gulp.task("favicons", function () { | |
gulp.src("./src/img/favicon.png").pipe(favicons({ | |
appName: config.appName, | |
appDescription: config.appDescription, | |
developerName: config.developerName, | |
developerURL: config.url, | |
background: "#000000", | |
path: "favicons/", | |
url: config.url, | |
display: "standalone", | |
orientation: "portrait", | |
version: 1.0, | |
logging: true, | |
online: false, | |
html: "./public/favicons/favicons.html", | |
replace: true | |
})).pipe(gulp.dest("./public/favicons")); | |
}); | |
// Rename functions | |
var rename2000 = function(opt) { | |
// Remove -p100, -p50 and -p33 | |
opt.basename = opt.basename.replace(/-p\d+/, ''); | |
opt.extname = '.jpg'; | |
opt.suffix = '-2000px'; | |
return opt; | |
}; | |
var rename1280 = function(opt) { | |
opt.basename = opt.basename.replace(/-p\d+/, ''); | |
opt.extname = '.jpg'; | |
opt.suffix = '-1280px'; | |
return opt; | |
}; | |
var rename640 = function(opt) { | |
opt.basename = opt.basename.replace(/-p\d+/, ''); | |
opt.extname = '.jpg'; | |
opt.suffix = '-640px'; | |
return opt; | |
}; | |
var rename320 = function(opt) { | |
opt.basename = opt.basename.replace(/-p\d+/, ''); | |
opt.extname = '.jpg'; | |
opt.suffix = '-320px'; | |
return opt; | |
}; | |
gulp.task('responsive', function () { | |
gulp.src(['./src/content/portfolio/**/*.png']) | |
.pipe(responsive({ | |
'**/*-p100.png': [ | |
{ | |
width: 2000, | |
rename: rename2000, | |
quality: 80 | |
},{ | |
width: 1280, | |
rename: rename1280, | |
quality: 85 | |
},{ | |
width: 640, | |
rename: rename640, | |
quality: 90 | |
} | |
], | |
'**/*-p50.png': [ | |
{ | |
width: 1280, | |
rename: rename1280, | |
quality: 85 | |
},{ | |
width: 640, | |
rename: rename640, | |
quality: 90 | |
} | |
], | |
'**/*-p33.png': [ | |
{ | |
width: 640, | |
rename: rename640, | |
quality: 90 | |
} | |
] | |
}, | |
{ | |
errorOnUnusedImage: false, | |
errorOnEnlargement: false // remove this when 50p images will be hi-res | |
} | |
)) | |
.pipe(gulp.dest('./public/img/portfolio/')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment