From 72af2cd387a9b1263d462217d6b579c00d507786 Mon Sep 17 00:00:00 2001 From: levfishbluefish Date: Tue, 17 Sep 2019 13:22:34 -0700 Subject: [PATCH] feat(jekyll): Speed up local builds Creates dev only gulp tasks and config files to speed up local build and watch times --- gulpfile.js | 57 ++++++++++++++++++------- jekyll-dev.yml | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 15 deletions(-) create mode 100644 jekyll-dev.yml diff --git a/gulpfile.js b/gulpfile.js index 4c2339cc3a05..9d9398067a16 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -89,25 +89,41 @@ function js() { return gulp.src(sources.js) .pipe($.plumber()) .pipe($.if(dev, $.sourcemaps.init())) - .pipe($.minify({ - noSource: true, - ext: { - min: '.js' - } - })) .pipe($.concat('app.js')) .pipe($.if(dev, $.sourcemaps.write())) .pipe(gulp.dest('dist/assets')) - .pipe($.size()) .pipe(browserSync.stream()) } +function js_min() { + return gulp.src(sources.js) + .pipe($.plumber()) + .pipe($.if(dev, $.sourcemaps.init())) + .pipe($.minify({ + noSource: true, + ext: { + min: '.js' + } + })) + .pipe($.concat('app.js')) + .pipe($.if(dev, $.sourcemaps.write())) + .pipe(gulp.dest('dist/assets')) + .pipe($.size()) + .pipe(browserSync.stream()) +} + function images() { return gulp.src(sources.images) .pipe($.plumber()) - .pipe($.imagemin()) .pipe(gulp.dest(paths.dist + 'assets/images')) - .pipe($.size()) +} + +function images_min() { + return gulp.src(sources.images) + .pipe($.plumber()) + .pipe($.imagemin()) + .pipe(gulp.dest(paths.dist + 'assets/images')) + .pipe($.size()) } function fonts() { @@ -119,7 +135,17 @@ function fonts() { } function jekyll(cb) { - var command = 'bundle exec jekyll build --config jekyll.yml --destination ' + paths.dist + var command = 'bundle exec jekyll build --config jekyll.yml --profile --destination ' + paths.dist + + childProcess.exec(command, function (err, stdout, stderr) { + log(stdout) + log(stderr) + cb(err) + }) +} + +function jekyll_dev(cb) { + var command = 'bundle exec jekyll build --config jekyll-dev.yml --profile --destination ' + paths.dist childProcess.exec(command, function (err, stdout, stderr) { log(stdout) @@ -131,8 +157,6 @@ function jekyll(cb) { function html() { return gulp.src(paths.dist + '/**/*.html') .pipe($.plumber()) - // Prefetch static assets - // .pipe($.resourceHints()) .pipe(gulp.dest(paths.dist)) .pipe($.size()) } @@ -385,7 +409,7 @@ function clean() { } function watch_files() { - gulp.watch(sources.content, gulp.series(jekyll, html, reload)) + gulp.watch(sources.content, gulp.series(jekyll_dev, html, reload)) gulp.watch(sources.styles, styles) gulp.watch(sources.images, gulp.series(images, reload)) gulp.watch(sources.js, gulp.series(js, reload)) @@ -401,11 +425,14 @@ function set_dev(cb) { // Basic Tasks gulp.task("js", js) +gulp.task("js_min", js_min) gulp.task("css", css) gulp.task("styles", styles) gulp.task("images", images) +gulp.task("images_min", images_min) gulp.task("fonts", fonts) gulp.task("jekyll", jekyll) +gulp.task("jekyll_dev", jekyll_dev) gulp.task("html", html) // Lua Tasks @@ -429,6 +456,6 @@ gulp.task("watch", gulp.series(browser_sync, watch_files)) gulp.task("dev", gulp.series(set_dev, clean, gulp.parallel(js, images, fonts, css), jekyll, html, styles, browser_sync, watch_files)) -gulp.task('default', gulp.series(clean, gulp.parallel(js, images, fonts, css), jekyll, html, styles, browser_sync, watch_files)) +gulp.task('default', gulp.series(clean, gulp.parallel(js, images, fonts, css), jekyll_dev, html, styles, browser_sync, watch_files)) -gulp.task("deploy", gulp.series(gulp.parallel(js, images, fonts, css), jekyll, html, styles, gh_pages)) +gulp.task("deploy", gulp.series(gulp.parallel(js_min, images_min, fonts, css), jekyll, html, styles, gh_pages)) diff --git a/jekyll-dev.yml b/jekyll-dev.yml new file mode 100644 index 000000000000..6f1209d7c662 --- /dev/null +++ b/jekyll-dev.yml @@ -0,0 +1,110 @@ +# Build settings +source: app +destination: dist +permalink: pretty +timezone: America/San_Francisco +markdown: kramdown +incremental: true + +kramdown: + syntax_highlighter_opts: + disable : true + +keep_files: + - assets + +# Site settings +name: Kong +title: Open-Source API Management and Microservice Management +description: "Secure, Manage & Extend your APIs or Microservices with plugins for authentication, logging, rate-limiting, transformations and more." +links: + web: https://docs.konghq.com + share: https://docs.konghq.com # legacy link, must maintain for social sharing counters + download: https://bintray.com/kong + instaclustr: "https://www.instaclustr.com/products/kong/?utm_source=partnership&utm_medium=link&utm_campaign=mashape" +repos: + kong: https://github.com/Kong/kong + docs: https://github.com/Kong/docs.konghq.com + vagrant: https://github.com/Kong/kong-vagrant + homebrew: https://github.com/Kong/homebrew-kong + cloudformation: https://github.com/Kong/kong-dist-cloudformation + oauth2_hello_world: https://github.com/Kong/kong-oauth2-hello-world + +collections: + hub: + output: true + layout: extension + +# for Kong platform extensions (not Jekyll) +extensions: + categories: + - name: Authentication + slug: authentication + desc: Protect your services with an authentication layer + - name: Security + slug: security + desc: Protect your services with additional security layer + - name: Traffic Control + slug: traffic-control + desc: Manage, throttle and restrict inbound and outbound API traffic + - name: Serverless + slug: serverless + desc: Invoke serverless functions in combination with other plugins + - name: Analytics & Monitoring + slug: analytics-monitoring + desc: Visualize, inspect and monitor APIs and microservices traffic + - name: Transformations + slug: transformations + desc: Transform request and responses on the fly on Kong + - name: Logging + slug: logging + desc: Log request and response data using the best transport for your infrastructure + - name: Deployment + slug: deployment + desc: Deploy and configure Kong in many environments + types: + - name: plugin + slug: plugin + - name: integration + slug: integration + # - name: dev portal extension + # slug: dev-mod + +exclude: + - node_modules + - jekyll-cache + +# location vars +icons_dir: assets/images/icons + +plugins: + - jekyll-redirect-from + +defaults: + - scope: + path: '' + values: + layout: 'docs' + + - scope: + path: 'install' + values: + layout: 'install' + + - scope: + path: 'docs/ee' + values: + layout: 'docs' + + - scope: + path: 'about' + values: + layout: 'about' + header_html: 'Star Fork' + breadcrumbs: null + + - scope: + type: hub + values: + layout: extension + permalink: /:collection/:path