1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-22 01:36:55 +01:00

build tweaks

- shorter jekyll task
- autoreload on gulpfile.js changes
- cache font files for longer time
This commit is contained in:
Matthias Kretschmann 2017-03-04 23:08:40 +01:00
parent 8d21edcb9e
commit 66c92d8031
Signed by: m
GPG Key ID: BD3C1F3EDD7831FC
2 changed files with 31 additions and 10 deletions

1
.gitignore vendored
View File

@ -4,5 +4,6 @@ Gemfile.lock
_dist _dist
.awspublish* .awspublish*
yarn.lock yarn.lock
.yarnclean
.bundle .bundle
vendor/ vendor/

View File

@ -8,7 +8,8 @@ var gulp = require('gulp'),
del = require('del'), del = require('del'),
pkg = require('./package.json'), pkg = require('./package.json'),
parallelize = require('concurrent-transform'), parallelize = require('concurrent-transform'),
browser = require('browser-sync'); browser = require('browser-sync').create(),
spawn = require('child_process').spawn;
// Temporary solution until gulp 4 // Temporary solution until gulp 4
// https://github.com/gulpjs/gulp/issues/355 // https://github.com/gulpjs/gulp/issues/355
@ -49,7 +50,7 @@ console.log("");
var PORT = 1337; var PORT = 1337;
// Browsers to target when prefixing CSS // Browsers to target when prefixing CSS
var COMPATIBILITY = ['Chrome >= 30', 'Safari >= 6.1', 'Firefox >= 35', 'Opera >= 32', 'iOS >= 8', 'Android >= 4', 'ie >= 10']; var COMPATIBILITY = ['last 2 versions', 'Chrome >= 30', 'Safari >= 6.1', 'Firefox >= 35', 'Opera >= 32', 'iOS >= 8', 'Android >= 4', 'ie >= 10'];
// paths // paths
var SRC = '_src/', var SRC = '_src/',
@ -110,16 +111,14 @@ gulp.task('jekyll', function(cb) {
browser.notify('Compiling Jekyll'); browser.notify('Compiling Jekyll');
var spawn = require('cross-spawn');
if (isProduction) { if (isProduction) {
process.env.JEKYLL_ENV = 'production'; var jekyll_options = 'jekyll build';
var jekyll = spawn('bundle', ['exec', 'jekyll', 'build'], { stdio: 'inherit' });
} else { } else {
process.env.JEKYLL_ENV = 'development'; var jekyll_options = 'jekyll build --incremental --drafts --future';
var jekyll = spawn('bundle', ['exec', 'jekyll', 'build', '--incremental', '--drafts', '--future'], { stdio: 'inherit' });
} }
var jekyll = spawn('bundle', ['exec', jekyll_options], { 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);
}); });
@ -256,7 +255,7 @@ gulp.task('rev:replace', function() {
if (isProduction) { if (isProduction) {
var manifest = gulp.src(DIST + '/assets/rev-manifest.json'); var manifest = gulp.src(DIST + '/assets/rev-manifest.json');
return gulp.src(DIST + '/**/*.{html,xml,txt,json,css,js,svg}') return gulp.src(DIST + '/**/*.{html,xml,txt,json,css,js}')
.pipe($.revReplace({ manifest: manifest })) .pipe($.revReplace({ manifest: manifest }))
.pipe(gulp.dest(DIST)); .pipe(gulp.dest(DIST));
} }
@ -275,6 +274,26 @@ gulp.task('server', ['build'], function() {
}); });
//
// Autoreload on gulpfile.js changes
//
gulp.task('gulp-autoreload', function() {
// Store current process if any
var p;
gulp.watch('gulpfile.js', spawnChildren);
spawnChildren();
function spawnChildren(e) {
if(p) {
p.kill();
}
p = spawn('gulp', { stdio: 'inherit' });
}
});
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Task sequences // Task sequences
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -290,6 +309,7 @@ gulp.task('default', ['build', 'server'], function() {
gulp.watch([SRC + '_assets/images/**/*.{svg}'], ['svg', browser.reload]); gulp.watch([SRC + '_assets/images/**/*.{svg}'], ['svg', browser.reload]);
gulp.watch([SRC + '_assets/videos/**/*.{mp4,webm}'], ['videos', browser.reload]); gulp.watch([SRC + '_assets/videos/**/*.{mp4,webm}'], ['videos', browser.reload]);
gulp.watch([SRC + '**/*.{html,xml,json,txt,md,yml}', './_config.yml', SRC + '_includes/svg/*'], ['build', browser.reload]); gulp.watch([SRC + '**/*.{html,xml,json,txt,md,yml}', './_config.yml', SRC + '_includes/svg/*'], ['build', browser.reload]);
gulp.watch('gulpfile.js', [ 'gulp-autoreload' ]);
}); });
@ -360,7 +380,7 @@ gulp.task('deploy', function() {
}, },
routes: { routes: {
// all static assets, cached & gzipped // all static assets, cached & gzipped
'^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf)$': { '^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf|eot|woff|woff2)$': {
cacheTime: 2592000, // cache for 1 month cacheTime: 2592000, // cache for 1 month
gzip: true gzip: true
}, },