mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
more refinements
This commit is contained in:
parent
6cf3fc1d37
commit
72c8b3d7fe
53
gulpfile.js
53
gulpfile.js
@ -18,14 +18,17 @@ var runSequence = require('run-sequence');
|
|||||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
var src = '_src',
|
var src = '_src',
|
||||||
dist = '_site';
|
dist = '_site',
|
||||||
|
cdn = 'https://d2jlreog722xe2.cloudfront.net';
|
||||||
|
|
||||||
var banner = [
|
var banner = [
|
||||||
'/**',
|
'/**',
|
||||||
' ** <%= pkg.name %> - <%= pkg.description %>',
|
' ** <%= pkg.name %> v<%= pkg.version %>',
|
||||||
|
' ** <%= pkg.description %>',
|
||||||
|
' ** <%= pkg.homepage %>\n' +
|
||||||
|
' **\n' +
|
||||||
' ** <%= pkg.repository.url %>',
|
' ** <%= pkg.repository.url %>',
|
||||||
' ** @author <%= pkg.author %>',
|
' ** <%= pkg.author.name %> <<%= pkg.author.email %>>',
|
||||||
' ** @version v<%= pkg.version %>',
|
|
||||||
' **/',
|
' **/',
|
||||||
''
|
''
|
||||||
].join('\n');
|
].join('\n');
|
||||||
@ -50,7 +53,16 @@ gulp.task('clean', function(cb) {
|
|||||||
//
|
//
|
||||||
gulp.task('jekyll', function (cb){
|
gulp.task('jekyll', function (cb){
|
||||||
var spawn = require('child_process').spawn;
|
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) {
|
jekyll.on('exit', function(code) {
|
||||||
cb(code === 0 ? null : 'ERROR: Jekyll process exited with code: '+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')
|
CustomElements = gulp.src('node_modules/webcomponents.js/CustomElements.js')
|
||||||
|
|
||||||
return merge(jquery, picturefill, CustomElements)
|
return merge(jquery, picturefill, CustomElements)
|
||||||
|
.pipe($.uglify())
|
||||||
.pipe($.rename({suffix: '.min'}))
|
.pipe($.rename({suffix: '.min'}))
|
||||||
.pipe(gulp.dest(dist + '/assets/js/'))
|
.pipe(gulp.dest(dist + '/assets/js/'))
|
||||||
});
|
});
|
||||||
@ -151,13 +164,13 @@ gulp.task('media', function() {
|
|||||||
//
|
//
|
||||||
gulp.task('imagemin', function () {
|
gulp.task('imagemin', function () {
|
||||||
return gulp.src(dist + '/**/*.{png,jpg,jpeg,gif,svg}')
|
return gulp.src(dist + '/**/*.{png,jpg,jpeg,gif,svg}')
|
||||||
.pipe($.imagemin({
|
.pipe($.cache($.imagemin({
|
||||||
optimizationLevel: 5, // png
|
optimizationLevel: 4, // png
|
||||||
progressive: true, // jpg
|
progressive: true, // jpg
|
||||||
interlaced: true, // gif
|
interlaced: true, // gif
|
||||||
multipass: true, // svg
|
multipass: true, // svg
|
||||||
svgoPlugins: [{removeViewBox: false}]
|
svgoPlugins: [{removeViewBox: false}]
|
||||||
}))
|
})))
|
||||||
.pipe(gulp.dest(dist));
|
.pipe(gulp.dest(dist));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,6 +200,26 @@ gulp.task('revision-replace', function() {
|
|||||||
.pipe(gulp.dest(dist));
|
.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
|
// Dev Server
|
||||||
//
|
//
|
||||||
@ -226,16 +259,18 @@ gulp.task('server', function(cb) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Production build
|
// Production build
|
||||||
//
|
//
|
||||||
gulp.task('build', function(cb) {
|
gulp.task('build', function(cb) {
|
||||||
runSequence(
|
runSequence(
|
||||||
'clean',
|
'clean',
|
||||||
'jekyll',
|
'jekyll:production',
|
||||||
['css', 'js', 'images', 'fonts', 'media'],
|
['css', 'js', 'images', 'fonts', 'media'],
|
||||||
'revision',
|
'revision',
|
||||||
'revision-replace',
|
'revision-replace',
|
||||||
|
'cdn',
|
||||||
'imagemin',
|
'imagemin',
|
||||||
cb
|
cb
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "kremalicious",
|
"name": "kremalicious",
|
||||||
"author": "Matthias Kretschmann <m@kretschmann.io>",
|
"author": {
|
||||||
|
"name": "Matthias Kretschmann",
|
||||||
|
"email": "m@kretschmann.io"
|
||||||
|
},
|
||||||
"description": "Blog of Matthias Kretschmann",
|
"description": "Blog of Matthias Kretschmann",
|
||||||
|
"homepage": "https://kremalicious.com",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "gulpfile.js",
|
"main": "gulpfile.js",
|
||||||
@ -21,6 +25,7 @@
|
|||||||
"del": ">=1.2.0",
|
"del": ">=1.2.0",
|
||||||
"gulp": ">=3.8.0",
|
"gulp": ">=3.8.0",
|
||||||
"gulp-autoprefixer": ">=2.3.0",
|
"gulp-autoprefixer": ">=2.3.0",
|
||||||
|
"gulp-cache": ">=0.2.10",
|
||||||
"gulp-combine-mq": ">=0.4.0",
|
"gulp-combine-mq": ">=0.4.0",
|
||||||
"gulp-concat": ">=2.5.2",
|
"gulp-concat": ">=2.5.2",
|
||||||
"gulp-connect": ">=2.0.5",
|
"gulp-connect": ">=2.0.5",
|
||||||
@ -29,6 +34,7 @@
|
|||||||
"gulp-imagemin": ">=2.2.1",
|
"gulp-imagemin": ">=2.2.1",
|
||||||
"gulp-load-plugins": ">=0.10.0",
|
"gulp-load-plugins": ">=0.10.0",
|
||||||
"gulp-rename": ">=1.2.2",
|
"gulp-rename": ">=1.2.2",
|
||||||
|
"gulp-replace": ">=0.5.3",
|
||||||
"gulp-rev": ">=4.0.0",
|
"gulp-rev": ">=4.0.0",
|
||||||
"gulp-rev-replace": ">=0.4.1",
|
"gulp-rev-replace": ">=0.4.1",
|
||||||
"gulp-stylus": ">=2.0.3",
|
"gulp-stylus": ">=2.0.3",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user