2013-11-18 01:08:13 +01:00
|
|
|
module.exports = function(grunt){
|
|
|
|
'use strict';
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// config
|
|
|
|
var gruntConfig = {
|
|
|
|
src: '_src',
|
2013-12-11 21:14:17 +01:00
|
|
|
site: '_site',
|
2013-12-11 23:47:20 +01:00
|
|
|
build: '_build',
|
2014-09-07 20:31:47 +02:00
|
|
|
cdnurl: 'https://d2jlreog722xe2.cloudfront.net',
|
2013-11-18 01:08:13 +01:00
|
|
|
assets: {
|
2014-07-12 02:07:09 +02:00
|
|
|
stylus: 'assets/styl',
|
2013-11-18 01:08:13 +01:00
|
|
|
css: 'assets/css',
|
|
|
|
js: 'assets/js',
|
2013-12-11 21:36:43 +01:00
|
|
|
img: 'assets/img',
|
2014-09-07 20:31:47 +02:00
|
|
|
fonts: 'assets/fonts'
|
2013-11-18 01:08:13 +01:00
|
|
|
}
|
|
|
|
};
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// banner
|
|
|
|
grunt.log.writeln("");
|
2013-11-23 18:14:41 +01:00
|
|
|
grunt.log.writeln(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
2013-11-18 01:08:13 +01:00
|
|
|
grunt.log.writeln("");
|
2013-11-23 21:53:52 +01:00
|
|
|
grunt.log.writeln(" (o) Just what do you think you're doing, Matthias? ");
|
2013-11-18 01:08:13 +01:00
|
|
|
grunt.log.writeln("");
|
2013-11-23 18:14:41 +01:00
|
|
|
grunt.log.writeln(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
2013-11-18 01:08:13 +01:00
|
|
|
grunt.log.writeln("");
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// Grunt config
|
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
config: gruntConfig,
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// clean everything
|
|
|
|
clean: {
|
2013-12-11 23:47:20 +01:00
|
|
|
site: [
|
2014-07-02 13:33:27 +02:00
|
|
|
'<%= config.site %>/*',
|
2013-12-08 17:35:57 +01:00
|
|
|
'<%= config.site %>/.htaccess',
|
2013-11-24 01:05:20 +01:00
|
|
|
'!<%= config.site %>/media'
|
2013-12-11 23:47:20 +01:00
|
|
|
],
|
|
|
|
build: [
|
2014-07-02 13:33:27 +02:00
|
|
|
'<%= config.build %>/*',
|
2013-12-11 23:47:20 +01:00
|
|
|
'<%= config.build %>/.htaccess'
|
2013-11-24 01:05:20 +01:00
|
|
|
]
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
// Jekyll
|
|
|
|
jekyll: {
|
2013-11-29 00:01:40 +01:00
|
|
|
options: {
|
|
|
|
src : '<%= config.src %>/',
|
2014-07-10 16:34:01 +02:00
|
|
|
config: './_config.yml'
|
2013-11-29 00:01:40 +01:00
|
|
|
},
|
2013-11-24 17:31:03 +01:00
|
|
|
production: {
|
2013-11-29 00:01:40 +01:00
|
|
|
options: {
|
2014-09-07 20:31:47 +02:00
|
|
|
lsi: true
|
2013-11-29 00:01:40 +01:00
|
|
|
}
|
2013-11-24 19:15:34 +01:00
|
|
|
},
|
2013-11-29 00:01:40 +01:00
|
|
|
development: {
|
|
|
|
options: {
|
|
|
|
drafts: true,
|
|
|
|
future: true,
|
2014-07-02 13:33:27 +02:00
|
|
|
//limit_posts: 5
|
2013-11-29 00:01:40 +01:00
|
|
|
}
|
2013-11-23 15:37:55 +01:00
|
|
|
}
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2014-07-12 02:07:09 +02:00
|
|
|
// Stylus
|
|
|
|
stylus: {
|
|
|
|
compile: {
|
|
|
|
options: {
|
2014-07-12 21:22:47 +02:00
|
|
|
'include css': true,
|
|
|
|
compress: false
|
|
|
|
},
|
2013-11-18 01:08:13 +01:00
|
|
|
files: {
|
2014-07-12 02:07:09 +02:00
|
|
|
'<%= config.site %>/<%= config.assets.css %>/kremalicious3.min.css' : '<%= config.src %>/<%= config.assets.stylus %>/kremalicious3.styl',
|
|
|
|
'<%= config.site %>/<%= config.assets.css %>/poststyle-2300.min.css' : '<%= config.src %>/<%= config.assets.stylus %>/poststyle-2300.styl'
|
2014-07-12 21:22:47 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// combine css media queries
|
|
|
|
cmq: {
|
|
|
|
production: {
|
|
|
|
files: {
|
2013-11-18 22:09:20 +01:00
|
|
|
'<%= config.site %>/<%= config.assets.css %>/': ['<%= config.site %>/<%= config.assets.css %>/kremalicious3.min.css']
|
2013-11-18 01:08:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// minify css
|
|
|
|
cssmin: {
|
|
|
|
production: {
|
|
|
|
files: {
|
2013-11-19 23:21:19 +01:00
|
|
|
'<%= config.site %>/<%= config.assets.css %>/kremalicious3.min.css': ['<%= config.site %>/<%= config.assets.css %>/*.css'],
|
|
|
|
'<%= config.site %>/<%= config.assets.css %>/poststyle-2300.min.css': ['<%= config.site %>/<%= config.assets.css %>/poststyle-2300.min.css']
|
2013-11-18 01:08:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// Concatenate and minify js
|
|
|
|
uglify: {
|
2013-11-25 22:00:15 +01:00
|
|
|
options: {
|
|
|
|
report: 'min'
|
|
|
|
},
|
2013-11-18 01:08:13 +01:00
|
|
|
production: {
|
|
|
|
files: {
|
2013-11-25 22:00:15 +01:00
|
|
|
'<%= config.site %>/<%= config.assets.js %>/picturefill.min.js': [
|
2014-07-02 13:33:27 +02:00
|
|
|
'bower_components/picturefill/dist/picturefill.js'
|
2013-11-23 21:53:52 +01:00
|
|
|
],
|
2013-11-18 22:09:20 +01:00
|
|
|
'<%= config.site %>/<%= config.assets.js %>/kremalicious3.min.js': [
|
2014-07-22 22:07:37 +02:00
|
|
|
'bower_components/jquery/dist/jquery.js',
|
2014-08-10 01:17:16 +02:00
|
|
|
'bower_components/jquery-infinite-scroll/jquery.infinitescroll.js',
|
|
|
|
'bower_components/masonry/dist/masonry.pkgd.js',
|
2013-11-29 21:36:09 +01:00
|
|
|
'bower_components/imagesloaded/imagesloaded.js',
|
2013-11-30 17:13:19 +01:00
|
|
|
'bower_components/simpleJekyllSearch/index.js',
|
2013-12-15 13:16:54 +01:00
|
|
|
'bower_components/jquery.adaptive-background/index.js',
|
2013-11-22 00:06:00 +01:00
|
|
|
'<%= config.src %>/<%= config.assets.js %>/app.js'
|
2013-11-18 01:08:13 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// image optimization
|
|
|
|
imagemin: {
|
|
|
|
assets: {
|
2013-11-24 19:15:34 +01:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.site %>/<%= config.assets.img %>/',
|
|
|
|
src: ['**/*.{png,jpg,jpeg,gif}'],
|
|
|
|
dest: '<%= config.site %>/<%= config.assets.img %>/'
|
|
|
|
}]
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
2013-11-22 00:35:07 +01:00
|
|
|
media: {
|
2013-11-24 19:15:34 +01:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.site %>/media/',
|
|
|
|
src: ['**/*.{png,gif}'],
|
|
|
|
dest: '<%= config.site %>/media/'
|
|
|
|
}]
|
2013-11-22 00:35:07 +01:00
|
|
|
},
|
2013-11-18 01:08:13 +01:00
|
|
|
touchicons: {
|
2013-11-24 19:15:34 +01:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.site %>/',
|
|
|
|
src: ['*.png'],
|
|
|
|
dest: '<%= config.site %>/'
|
|
|
|
}]
|
2013-11-24 01:05:20 +01:00
|
|
|
}
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// dev server
|
|
|
|
connect: {
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 1337,
|
2013-11-21 23:40:53 +01:00
|
|
|
hostname: '*',
|
2013-11-30 17:13:19 +01:00
|
|
|
base: '<%= config.site %>'
|
2013-11-18 01:08:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// watch
|
|
|
|
watch: {
|
|
|
|
options: {
|
|
|
|
livereload: true
|
|
|
|
},
|
2014-07-12 02:07:09 +02:00
|
|
|
stylus: {
|
|
|
|
files: ['<%= config.src %>/<%= config.assets.stylus %>/*.styl'],
|
2014-07-12 21:22:47 +02:00
|
|
|
tasks: ['stylus', 'cmq', 'cssmin']
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
|
|
|
js: {
|
|
|
|
files: ['<%= config.src %>/<%= config.assets.js %>/*.js'],
|
|
|
|
tasks: ['uglify']
|
|
|
|
},
|
|
|
|
jekyll: {
|
|
|
|
files: [
|
2014-07-02 13:33:27 +02:00
|
|
|
'<%= config.src %>/**/*.html',
|
|
|
|
'<%= config.src %>/*.xml',
|
2013-12-08 17:35:57 +01:00
|
|
|
'<%= config.src %>/*.json',
|
|
|
|
'<%= config.src %>/.htaccess',
|
|
|
|
'<%= config.src %>/_includes/**',
|
2013-11-18 22:09:20 +01:00
|
|
|
'<%= config.src %>/_layouts/**',
|
2013-11-29 00:01:40 +01:00
|
|
|
'<%= config.src %>/_posts/**',
|
|
|
|
'<%= config.src %>/_drafts/**'
|
2013-11-18 01:08:13 +01:00
|
|
|
],
|
2014-07-12 02:07:09 +02:00
|
|
|
tasks: ['jekyll:development', 'stylus', 'cmq', 'cssmin', 'uglify']
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-12-11 21:36:43 +01:00
|
|
|
// assets versioning
|
|
|
|
rev: {
|
|
|
|
files: {
|
|
|
|
src: [
|
2013-12-15 13:16:54 +01:00
|
|
|
'<%= config.build %>/assets/{css,js,img,fonts}/*.*'
|
2013-12-11 21:36:43 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-12-11 21:36:43 +01:00
|
|
|
// updating assets paths in html/css
|
|
|
|
usemin: {
|
2013-12-15 13:16:54 +01:00
|
|
|
html: ['<%= config.build %>/**/*.html'],
|
|
|
|
css: ['<%= config.build %>/**/*.css'],
|
2013-12-11 21:36:43 +01:00
|
|
|
options: {
|
2013-12-15 14:15:23 +01:00
|
|
|
dirs: '<%= config.build %>',
|
|
|
|
basedir: '<%= config.build %>',
|
2013-12-15 14:30:41 +01:00
|
|
|
assetsDirs: ['<%= config.build %>', '<%= config.build %>/assets/{css,js,img,fonts}']
|
2013-12-11 21:36:43 +01:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 20:31:47 +02:00
|
|
|
|
|
|
|
// insert CDN url by replacing text strings
|
|
|
|
replace: {
|
|
|
|
html: {
|
|
|
|
src: ['<%= config.build %>/**/*.html'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [
|
|
|
|
{
|
|
|
|
from: '/assets/js/',
|
|
|
|
to: '<%= config.cdnurl %>/assets/js/'
|
|
|
|
},
|
2014-09-07 22:04:38 +02:00
|
|
|
{
|
|
|
|
from: '/assets/img/',
|
|
|
|
to: '<%= config.cdnurl %>/assets/img/'
|
|
|
|
},
|
2014-09-07 20:31:47 +02:00
|
|
|
{
|
|
|
|
from: '/media/',
|
|
|
|
to: '<%= config.cdnurl %>/media/'
|
2014-10-13 10:28:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'https://kremalicious.com<%= config.cdnurl %>/media/',
|
|
|
|
to: 'https://kremalicious.com/media/'
|
2014-09-07 20:31:47 +02:00
|
|
|
}
|
|
|
|
]
|
2014-09-06 15:30:15 +02:00
|
|
|
},
|
2014-09-07 20:31:47 +02:00
|
|
|
css: {
|
|
|
|
src: ['<%= config.build %>/<%= config.assets.css %>/*.css'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [
|
|
|
|
{
|
|
|
|
from: '../',
|
|
|
|
to: '<%= config.cdnurl %>/assets/'
|
|
|
|
}
|
2014-09-06 15:30:15 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-23 18:14:41 +01:00
|
|
|
// rsync stuff around
|
2013-11-18 01:08:13 +01:00
|
|
|
rsync: {
|
|
|
|
options: {
|
2013-11-23 18:14:41 +01:00
|
|
|
recursive: true
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
2013-11-23 18:14:41 +01:00
|
|
|
// copy media folder
|
|
|
|
copy_media: {
|
2013-11-18 01:08:13 +01:00
|
|
|
options: {
|
2013-11-23 18:14:41 +01:00
|
|
|
src: '<%= config.src %>/_media/',
|
2013-11-24 17:31:03 +01:00
|
|
|
dest: '<%= config.site %>/media',
|
|
|
|
exclude: ['**/gen'],
|
2014-01-02 18:13:03 +01:00
|
|
|
syncDestIgnoreExcl: true,
|
|
|
|
args: ['--update']
|
2013-11-23 18:14:41 +01:00
|
|
|
}
|
|
|
|
},
|
2013-12-11 23:47:20 +01:00
|
|
|
// copy build
|
|
|
|
copy_build: {
|
|
|
|
options: {
|
|
|
|
src: '<%= config.site %>/',
|
|
|
|
dest: '<%= config.build %>',
|
|
|
|
syncDest: true
|
|
|
|
}
|
|
|
|
},
|
2013-11-23 18:14:41 +01:00
|
|
|
// deployment
|
|
|
|
deploy: {
|
|
|
|
options: {
|
|
|
|
syncDest: true,
|
2013-12-11 23:47:20 +01:00
|
|
|
src: '<%= config.build %>/',
|
2013-11-24 17:31:03 +01:00
|
|
|
dest: 'domains/kremalicious.com/html',
|
2013-11-23 18:14:41 +01:00
|
|
|
host: 'kremalicious',
|
|
|
|
ssh: true,
|
2014-01-02 18:13:03 +01:00
|
|
|
compareMode: 'checksum',
|
2013-11-29 00:01:40 +01:00
|
|
|
args: ['--verbose']
|
2013-11-18 01:08:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
});
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// Load NPM Tasks, smart code stolen from @bluemaex <https://github.com/bluemaex>
|
|
|
|
require('fs').readdirSync('node_modules').filter(function (file) {
|
|
|
|
return file && file.indexOf('grunt-') > -1;
|
|
|
|
}).forEach(function (file) {
|
|
|
|
grunt.loadNpmTasks(file);
|
|
|
|
});
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-12-11 23:47:20 +01:00
|
|
|
// Default Task, assets only
|
2013-11-18 01:08:13 +01:00
|
|
|
grunt.registerTask('default', [
|
2014-07-12 02:07:09 +02:00
|
|
|
'stylus',
|
2013-11-18 01:08:13 +01:00
|
|
|
'cmq',
|
|
|
|
'cssmin',
|
2013-11-22 00:06:00 +01:00
|
|
|
'uglify',
|
2013-11-18 01:08:13 +01:00
|
|
|
'connect',
|
|
|
|
'watch'
|
|
|
|
]);
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-12-10 21:08:28 +01:00
|
|
|
// Full Dev server
|
2013-11-23 18:48:45 +01:00
|
|
|
grunt.registerTask('server', [
|
2013-12-11 23:47:20 +01:00
|
|
|
'clean:site',
|
2013-11-29 00:01:40 +01:00
|
|
|
'jekyll:development',
|
2013-12-11 21:36:43 +01:00
|
|
|
'rsync:copy_media',
|
2014-07-12 02:07:09 +02:00
|
|
|
'stylus',
|
2013-11-23 18:14:41 +01:00
|
|
|
'cmq',
|
|
|
|
'cssmin',
|
|
|
|
'uglify',
|
|
|
|
'connect',
|
|
|
|
'watch'
|
|
|
|
]);
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// Production build
|
|
|
|
grunt.registerTask('build', [
|
|
|
|
'clean',
|
2013-11-24 19:15:34 +01:00
|
|
|
'jekyll:production',
|
2013-12-11 21:36:43 +01:00
|
|
|
'rsync:copy_media',
|
2014-07-12 02:07:09 +02:00
|
|
|
'stylus',
|
2013-11-18 01:08:13 +01:00
|
|
|
'cmq',
|
|
|
|
'cssmin',
|
2013-12-11 21:36:43 +01:00
|
|
|
'uglify',
|
2014-07-22 23:18:03 +02:00
|
|
|
'imagemin:assets',
|
|
|
|
'imagemin:touchicons',
|
2013-12-15 13:16:54 +01:00
|
|
|
'rsync:copy_build',
|
|
|
|
'rev',
|
2014-09-06 15:30:15 +02:00
|
|
|
'usemin',
|
2014-09-07 20:31:47 +02:00
|
|
|
'replace'
|
2013-12-11 23:47:20 +01:00
|
|
|
]);
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-12-11 23:47:20 +01:00
|
|
|
// Optimze media
|
|
|
|
grunt.registerTask('mediamin', [
|
|
|
|
'imagemin:media'
|
2013-11-18 01:08:13 +01:00
|
|
|
]);
|
2014-07-02 13:33:27 +02:00
|
|
|
|
2013-11-18 01:08:13 +01:00
|
|
|
// Deploy
|
|
|
|
grunt.registerTask('deploy', [
|
2013-11-23 18:14:41 +01:00
|
|
|
'rsync:deploy'
|
2013-11-18 01:08:13 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
};
|