1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 09:56:51 +01:00

more refinements

This commit is contained in:
Matthias Kretschmann 2015-06-07 03:11:46 +02:00
parent 6cf3fc1d37
commit 72c8b3d7fe
2 changed files with 51 additions and 10 deletions

View File

@ -18,14 +18,17 @@ var runSequence = require('run-sequence');
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
var src = '_src',
dist = '_site';
dist = '_site',
cdn = 'https://d2jlreog722xe2.cloudfront.net';
var banner = [
'/**',
' ** <%= pkg.name %> - <%= pkg.description %>',
' ** <%= pkg.name %> v<%= pkg.version %>',
' ** <%= pkg.description %>',
' ** <%= pkg.homepage %>\n' +
' **\n' +
' ** <%= pkg.repository.url %>',
' ** @author <%= pkg.author %>',
' ** @version v<%= pkg.version %>',
' ** <%= pkg.author.name %> <<%= pkg.author.email %>>',
' **/',
''
].join('\n');
@ -50,7 +53,16 @@ gulp.task('clean', function(cb) {
//
gulp.task('jekyll', function (cb){
var spawn = require('child_process').spawn;
var jekyll = spawn('jekyll', ['build'], {stdio: 'inherit'});
var jekyll = spawn('jekyll', ['build', '--drafts', '--future'], {stdio: 'inherit'});
jekyll.on('exit', function(code) {
cb(code === 0 ? null : 'ERROR: Jekyll process exited with code: '+code);
});
});
gulp.task('jekyll:production', function (cb){
var spawn = require('child_process').spawn;
var jekyll = spawn('jekyll', ['build', '--lsi'], {stdio: 'inherit'});
jekyll.on('exit', function(code) {
cb(code === 0 ? null : 'ERROR: Jekyll process exited with code: '+code);
@ -92,6 +104,7 @@ gulp.task('js-libraries', function() {
CustomElements = gulp.src('node_modules/webcomponents.js/CustomElements.js')
return merge(jquery, picturefill, CustomElements)
.pipe($.uglify())
.pipe($.rename({suffix: '.min'}))
.pipe(gulp.dest(dist + '/assets/js/'))
});
@ -151,13 +164,13 @@ gulp.task('media', function() {
//
gulp.task('imagemin', function () {
return gulp.src(dist + '/**/*.{png,jpg,jpeg,gif,svg}')
.pipe($.imagemin({
optimizationLevel: 5, // png
.pipe($.cache($.imagemin({
optimizationLevel: 4, // png
progressive: true, // jpg
interlaced: true, // gif
multipass: true, // svg
svgoPlugins: [{removeViewBox: false}]
}))
})))
.pipe(gulp.dest(dist));
});
@ -187,6 +200,26 @@ gulp.task('revision-replace', function() {
.pipe(gulp.dest(dist));
});
//
// CDN url injection
//
gulp.task('cdn',function(){
// html
return gulp.src([dist + '/**/*.html'])
.pipe($.replace('/assets/js/', cdn + '/assets/js/'))
.pipe($.replace('/assets/img/', cdn + '/assets/img/'))
.pipe($.replace('/media/', cdn + '/media/'))
.pipe($.replace('https://kremalicious.com' + cdn + '/media/', 'https://kremalicious.com/media/'))
.pipe(gulp.dest(dist));
// css
return gulp.src([dist + '/assets/css/*.css'])
.pipe($.replace('../', cdn + '/assets/'))
.pipe(gulp.dest(dist));
});
//
// Dev Server
//
@ -226,16 +259,18 @@ gulp.task('server', function(cb) {
);
});
//
// Production build
//
gulp.task('build', function(cb) {
runSequence(
'clean',
'jekyll',
'jekyll:production',
['css', 'js', 'images', 'fonts', 'media'],
'revision',
'revision-replace',
'cdn',
'imagemin',
cb
);

View File

@ -1,7 +1,11 @@
{
"name": "kremalicious",
"author": "Matthias Kretschmann <m@kretschmann.io>",
"author": {
"name": "Matthias Kretschmann",
"email": "m@kretschmann.io"
},
"description": "Blog of Matthias Kretschmann",
"homepage": "https://kremalicious.com",
"version": "3.0.0",
"license": "MIT",
"main": "gulpfile.js",
@ -21,6 +25,7 @@
"del": ">=1.2.0",
"gulp": ">=3.8.0",
"gulp-autoprefixer": ">=2.3.0",
"gulp-cache": ">=0.2.10",
"gulp-combine-mq": ">=0.4.0",
"gulp-concat": ">=2.5.2",
"gulp-connect": ">=2.0.5",
@ -29,6 +34,7 @@
"gulp-imagemin": ">=2.2.1",
"gulp-load-plugins": ">=0.10.0",
"gulp-rename": ">=1.2.2",
"gulp-replace": ">=0.5.3",
"gulp-rev": ">=4.0.0",
"gulp-rev-replace": ">=0.4.1",
"gulp-stylus": ">=2.0.3",