1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 18:00:06 +01:00
blog/Gruntfile.js

289 lines
8.4 KiB
JavaScript
Raw Normal View History

2013-11-18 01:08:13 +01:00
module.exports = function(grunt){
'use strict';
// config
var gruntConfig = {
src: '_src',
2013-12-11 21:14:17 +01:00
site: '_site',
2013-11-18 01:08:13 +01:00
assets: {
less: 'assets/less',
css: 'assets/css',
js: 'assets/js',
img: 'assets/img',
fonts: 'assets/fonts'
2013-11-18 01:08:13 +01:00
}
};
// banner
grunt.log.writeln("");
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("");
grunt.log.writeln(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
2013-11-18 01:08:13 +01:00
grunt.log.writeln("");
// Grunt config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
config: gruntConfig,
// clean everything
clean: {
2013-11-24 01:05:20 +01:00
build: [
'<%= config.site %>/*',
'<%= config.site %>/.htaccess',
2013-11-24 01:05:20 +01:00
'!<%= config.site %>/media'
]
2013-11-18 01:08:13 +01:00
},
// Jekyll
jekyll: {
2013-11-29 00:01:40 +01:00
options: {
src : '<%= config.src %>/',
config: './_config.yml'
},
2013-11-24 17:31:03 +01:00
production: {
2013-11-29 00:01:40 +01:00
options: {
//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,
2013-12-09 23:29:19 +01:00
//limit_posts: 50
2013-11-29 00:01:40 +01:00
}
2013-11-23 15:37:55 +01:00
}
2013-11-18 01:08:13 +01:00
},
// less
less: {
production: {
files: {
2013-11-19 23:21:19 +01:00
'<%= config.site %>/<%= config.assets.css %>/kremalicious3.min.css' : '<%= config.src %>/<%= config.assets.less %>/kremalicious3.less',
'<%= config.site %>/<%= config.assets.css %>/poststyle-2300.min.css' : '<%= config.src %>/<%= config.assets.less %>/poststyle-2300.less'
2013-11-18 01:08:13 +01:00
},
},
},
// combine css media queries
cmq: {
production: {
files: {
'<%= config.site %>/<%= config.assets.css %>/': ['<%= config.site %>/<%= config.assets.css %>/kremalicious3.min.css']
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
}
}
},
// Concatenate and minify js
uglify: {
options: {
report: 'min'
},
jquery: {
files: {
'<%= config.site %>/<%= config.assets.js %>/jquery.min.js': 'bower_components/jquery/jquery.js'
}
},
2013-11-18 01:08:13 +01:00
production: {
files: {
'<%= config.site %>/<%= config.assets.js %>/picturefill.min.js': [
'bower_components/picturefill/picturefill.js'
2013-11-23 21:53:52 +01:00
],
'<%= config.site %>/<%= config.assets.js %>/kremalicious3.min.js': [
'bower_components/infinitescroll/index.js',
2013-11-29 21:36:09 +01:00
'bower_components/masonry/index.js',
'bower_components/imagesloaded/imagesloaded.js',
2013-11-30 17:13:19 +01:00
'bower_components/simpleJekyllSearch/index.js',
2013-12-07 16:00:56 +01:00
'bower_components/socialite/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
]
}
}
},
// 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
},
// 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
}
}
},
// watch
watch: {
options: {
livereload: true
},
less: {
files: ['<%= config.src %>/<%= config.assets.less %>/*.less'],
2013-11-30 04:10:58 +01:00
tasks: ['less','cmq','cssmin']
2013-11-18 01:08:13 +01:00
},
js: {
files: ['<%= config.src %>/<%= config.assets.js %>/*.js'],
tasks: ['uglify']
},
jekyll: {
files: [
'<%= config.src %>/**/*.html',
2013-11-29 00:01:40 +01:00
'<%= config.src %>/*.xml',
'<%= config.src %>/*.json',
'<%= config.src %>/.htaccess',
'<%= config.src %>/_includes/**',
'<%= 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
],
2013-11-30 04:10:58 +01:00
tasks: ['jekyll:development', 'less', 'cmq', 'cssmin', 'uglify']
2013-11-18 01:08:13 +01:00
},
},
// assets versioning
rev: {
files: {
src: [
'<%= config.site %>/assets/{css,js,img,fonts}/*.*'
]
}
},
// updating assets paths in html/css
usemin: {
html: ['<%= config.site %>/**/*.html'],
css: ['<%= config.site %>/**/*.css'],
options: {
dirs: ['<%= config.site %>'],
basedir: ['<%= config.site %>']
}
},
// rsync stuff around
2013-11-18 01:08:13 +01:00
rsync: {
options: {
recursive: true
2013-11-18 01:08:13 +01:00
},
// copy media folder
copy_media: {
2013-11-18 01:08:13 +01:00
options: {
src: '<%= config.src %>/_media/',
2013-11-24 17:31:03 +01:00
dest: '<%= config.site %>/media',
exclude: ['**/gen'],
syncDestIgnoreExcl: true
}
},
// deployment
deploy: {
options: {
syncDest: true,
2013-11-18 01:08:13 +01:00
src: '<%= config.site %>/',
2013-11-24 17:31:03 +01:00
dest: 'domains/kremalicious.com/html',
host: 'kremalicious',
ssh: true,
2013-11-29 00:01:40 +01:00
args: ['--verbose']
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);
});
// Default Task
grunt.registerTask('default', [
'less',
'cmq',
'cssmin',
2013-11-22 00:06:00 +01:00
'uglify',
2013-11-18 01:08:13 +01:00
'connect',
'watch'
]);
2013-12-10 21:08:28 +01:00
// Full Dev server
2013-11-23 18:48:45 +01:00
grunt.registerTask('server', [
2013-11-29 00:01:40 +01:00
'jekyll:development',
'rsync:copy_media',
'less',
'cmq',
'cssmin',
'uglify',
'connect',
'watch'
]);
2013-11-22 00:35:07 +01:00
2013-12-10 21:08:28 +01:00
// Assets only Dev server
grunt.registerTask('server-assets', [
'less',
'cmq',
'cssmin',
'uglify',
'connect',
'watch'
]);
2013-11-18 01:08:13 +01:00
// Production build
grunt.registerTask('build', [
'clean',
2013-11-24 19:15:34 +01:00
'jekyll:production',
'rsync:copy_media',
2013-11-18 01:08:13 +01:00
'less',
'cmq',
'cssmin',
'uglify',
'rev',
'usemin',
'imagemin'
2013-11-18 01:08:13 +01:00
]);
// Deploy
grunt.registerTask('deploy', [
'rsync:deploy'
2013-11-18 01:08:13 +01:00
]);
};