gulp prod

This commit is contained in:
bchiang7
2016-12-08 23:34:45 -05:00
parent ea789e0928
commit ce307057a2
6 changed files with 2040 additions and 66 deletions

View File

@@ -11,8 +11,8 @@ keep_files:
# Site settings
baseurl: ""
title: Brittany Chiang | Front End Software Engineer
name: Brittany Chiang
title: Brittany Chiang | Front End Software Engineer
description: Design-minded, detail oriented software engineer passionate about combining beautiful code with beautiful design.
url: http://brittanychiang.com # the base hostname & protocol for your site
email: brittany.chiang@gmail.com

View File

@@ -9,7 +9,7 @@
<h1 class="heading" data-content="Brittany Chiang"><span class="name">Brittany Chiang</span></h1>
<div class="action-wrapper">
<p class="subtext">
<a class="btn main-action">Front-End Software Engineer</a>
<a class="btn main-action">Front End Software Engineer</a>
</p>
</div>
</div>

View File

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,7 @@ var cp = require('child_process');
var htmlmin = require('gulp-htmlmin');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
var autoprefix = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var prefix = require('gulp-autoprefixer');
var jshint = require('gulp-jshint');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
@@ -14,23 +13,24 @@ var deploy = require('gulp-gh-pages');
var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
jekyllDev: 'Running: $ jekyll build for dev',
jekyllProd: 'Running: $ jekyll build for prod'
};
// Build the Jekyll Site
gulp.task('jekyll-build', function(done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
gulp.task('jekyll-dev', function(done) {
browserSync.notify(messages.jekyllDev);
return cp.spawn( jekyll , ['build', '--drafts', '--config', '_config.yml'], {stdio: 'inherit'})
.on('close', done);
});
// Rebuild Jekyll & do page reload
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
// Rebuild Jekyll & reload the page
gulp.task('jekyll-rebuild', ['jekyll-dev'], function () {
browserSync.reload();
});
// Wait for jekyll-build, then launch the Server
gulp.task('browser-sync', ['styles', 'jekyll-build'], function() {
// Wait for jekyll-dev task to complete, then launch the Server
gulp.task('browser-sync', ['styles', 'scripts', 'jekyll-dev'], function() {
browserSync({
server: {
baseDir: '_site'
@@ -38,7 +38,6 @@ gulp.task('browser-sync', ['styles', 'jekyll-build'], function() {
});
});
gulp.task('htmlmin', function() {
return gulp.src('*.html')
.pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
@@ -53,8 +52,7 @@ gulp.task('styles', function() {
onError: browserSync.notify
})
)
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(autoprefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], {cascade: true}))
.pipe(gulp.dest('_site/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('css'));
@@ -67,8 +65,42 @@ gulp.task('scripts', function() {
.pipe(babel({
presets: ['es2015']
}))
//.pipe(concat('scripts.js'))
//.pipe(uglify())
.pipe(gulp.dest('_site/js'))
.pipe(browserSync.reload({stream:true}));
});
// Watch scss files for changes & recompile
// Watch html/md files, run jekyll & reload BrowserSync
gulp.task('watch', function () {
gulp.watch(['_scss/**/*.scss','_scss/*.scss'], ['styles']);
gulp.watch(['js/*.js'], ['scripts']);
gulp.watch(['index.html', '404.html', '_layouts/*.html', '_posts/*', '_includes/*.html', '_drafts/*', '**/*.html'], ['htmlmin', 'jekyll-rebuild']);
});
// Build the Jekyll Site in production mode
gulp.task('jekyll-prod', function (done) {
browserSync.notify(messages.jekyllProd);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
// Identical Sass compilation task to development mode, with an additional minification step thrown in using clean-css
gulp.task('styles-prod', function () {
return gulp.src('_sass/styles.scss')
.pipe(sass({
includePaths: ['scss'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('_site/css'))
.pipe(gulp.dest('css'));
});
// Identical Javascript compilation task to development mode, with an additional minification step thrown in using uglify
gulp.task('scripts-prod', function() {
return gulp.src(['js/*.js'])
.pipe(uglify())
.pipe(gulp.dest('_site/js'));
});
@@ -80,22 +112,17 @@ gulp.task('images', function() {
gulp.task('fonts', function() {
return gulp.src('fonts/**/*')
.pipe(gulp.dest('_site/fonts'))
})
// Watch scss files for changes & recompile
// Watch html/md files, run jekyll & reload BrowserSync
gulp.task('watch', function() {
gulp.watch(['*.html', '_layouts/*.html', '_includes/*.html', '_data/*.yml'], ['jekyll-rebuild']);
gulp.watch('_scss/**/*.scss', ['styles']);
gulp.watch('js/*.js', ['scripts']);
.pipe(gulp.dest('_site/fonts'));
});
// Default task, running just gulp will compile the sass, compile the Jekyll site, launch BrowserSync & watch files.
gulp.task('default', ['browser-sync', 'watch']);
// Build task, run using gulp build to compile Sass and Javascript ready for deployment.
gulp.task('build', ['fonts', 'images', 'styles-prod', 'scripts-prod', 'jekyll-prod']);
// deploy to github pages
gulp.task('deploy', ["jekyll-build"], function () {
return gulp.src("./_site/**/*")
.pipe(deploy());
});
// Default task, running just `gulp` will compile the sass, compile the jekyll site, launch BrowserSync & watch files.
gulp.task('default', ['browser-sync', 'watch']);

View File

@@ -1,34 +1,37 @@
$(function() {
const contentSections = $('.section');
const navigationItems = $('#dot-nav a');
const overlayItems = $('#overlay a');
$(window).on('scroll', () => { updateNavigation(); });
// ==================== VERTICAL NAV ==================== //
var contentSections = $('.section'),
navigationItems = $('#dot-nav a'),
overlayItems = $('#overlay a');
updateNavigation();
$(window).on('scroll', function() {
updateNavigation();
});
//smooth scroll to the section
navigationItems.on('click', event => {
navigationItems.on('click', function(event) {
event.preventDefault();
smoothScroll($(this.hash));
});
overlayItems.on('click', event => {
overlayItems.on('click', function(event) {
event.preventDefault();
smoothScroll($(this.hash));
$('#toggle').click();
});
// smooth scroll to second section
$('.scroll-down').on('click', event => {
$('.scroll-down').on('click', function(event) {
event.preventDefault();
smoothScroll($(this.hash));
});
// close navigation on touch devices when selectinG an elemnt from the list
$('.touch #dot-nav a').on('click', () => {
$('.touch #dot-nav a').on('click', function() {
$('.touch #dot-nav').removeClass('open');
});
// ==================== VERTICAL NAV ON SCROLL ==================== //
$(document).scroll( () => {
const x = $(window).width();
const y = $(this).scrollTop();
const $nav = $('#dot-nav');
$(document).scroll(function() {
var x = $(window).width();
var y = $(this).scrollTop();
var $nav = $('#dot-nav');
if (x > 768 && y > 500) {
$nav.fadeIn();
} else {
@@ -37,9 +40,9 @@ $(function() {
});
function updateNavigation() {
contentSections.each( () => {
const $this = $(this);
const activeSection = $('#dot-nav a[href="#' + $this.attr('id') + '"]').data('number') - 1;
contentSections.each(function() {
var $this = $(this);
var activeSection = $('#dot-nav a[href="#' + $this.attr('id') + '"]').data('number') - 1;
if (($this.offset().top - $(window).height() / 2 < $(window).scrollTop()) && ($this.offset().top + $this.height() - $(window).height() / 2 > $(window).scrollTop())) {
navigationItems.eq(activeSection).addClass('is-selected');
} else {
@@ -58,7 +61,7 @@ $(function() {
$('#overlay').toggleClass('open');
$('body').toggleClass('noScroll');
});
$(window).on('resize', event => {
$(window).on('resize', function(event) {
var windowWidth = $(window).width();
var isOpen = $('#overlay').hasClass('open');
@@ -74,7 +77,7 @@ $(function() {
});
// ==================== CONTACT FORM ==================== //
const $contactInput = $('.contact-input');
var $contactInput = $('.contact-input');
$contactInput.focus(function() {
$(this).parent().addClass('is-active is-completed');
});
@@ -85,12 +88,13 @@ $(function() {
$(this).parent().removeClass('is-active');
});
$(document).one('focus.textarea', '.autoExpand', () => {
const savedValue = this.value;
$(document).one('focus.textarea', '.autoExpand', function() {
var savedValue = this.value;
this.value = '';
this.baseScrollHeight = this.scrollHeight;
this.value = savedValue;
}).on('input.textarea', '.autoExpand', () => {
})
.on('input.textarea', '.autoExpand', function() {
var minRows = this.getAttribute('data-min-rows') | 0,
rows;
this.rows = minRows;
@@ -98,23 +102,23 @@ $(function() {
this.rows = minRows + rows;
});
const isMobile = {
Android() {
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry() {
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS() {
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera() {
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows() {
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any() {
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
@@ -129,11 +133,5 @@ $(function() {
forceHeight: false
});
}
});
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-84377262-1', 'auto');
ga('send', 'pageview');
});

View File

@@ -1,9 +1,9 @@
{
"name": "Brittany Chiang",
"author": "Brittany Chiang",
"version": "0.0.0",
"description": "Personal website of Brittany Chiang",
"main": "gulpfile.js",
"author": "Brittany Chiang",
"devDependencies": {
"babel-preset-es2015": "^6.18.0",
"browser-sync": "^2.18.2",
@@ -24,6 +24,9 @@
"type": "git",
"url": "https://github.com/bchiang7/bchiang7.github.io"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"jekyll",
"gulp",