2013-11-18 01:08:13 +01:00
|
|
|
module.exports = function(grunt){
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// config
|
|
|
|
var gruntConfig = {
|
|
|
|
src: '_src',
|
|
|
|
site: '_site',
|
|
|
|
assets: {
|
|
|
|
less: 'assets/less',
|
|
|
|
css: 'assets/css',
|
|
|
|
js: 'assets/js',
|
|
|
|
img: 'assets/img'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// banner
|
|
|
|
grunt.log.writeln("");
|
|
|
|
grunt.log.writeln(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
grunt.log.writeln("");
|
|
|
|
grunt.log.writeln(" Just what do you think you're doing, Matthias? ");
|
|
|
|
grunt.log.writeln("");
|
|
|
|
grunt.log.writeln(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
grunt.log.writeln("");
|
|
|
|
|
|
|
|
// Grunt config
|
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
config: gruntConfig,
|
|
|
|
|
|
|
|
// clean everything
|
|
|
|
clean: {
|
|
|
|
build: ['<%= config.site %>']
|
|
|
|
},
|
|
|
|
|
|
|
|
// Jekyll
|
|
|
|
jekyll: {
|
|
|
|
production : {
|
|
|
|
src: '<%= config.src %>'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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: {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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: {
|
|
|
|
production: {
|
|
|
|
options: {
|
|
|
|
report: 'min',
|
|
|
|
mangle: true
|
|
|
|
},
|
|
|
|
files: {
|
2013-11-18 22:09:20 +01:00
|
|
|
'<%= config.site %>/<%= config.assets.js %>/kremalicious3.min.js': [
|
2013-11-18 01:08:13 +01:00
|
|
|
'<%= config.src %>/<%= config.assets.js %>/script.js'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// image optimization
|
|
|
|
imagemin: {
|
|
|
|
assets: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.site %>/<%= config.assets.img %>/',
|
|
|
|
src: ['**/*.{png,jpg,jpeg,gif}'],
|
|
|
|
dest: '<%= config.site %>/<%= config.assets.img %>/'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
touchicons: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.site %>/',
|
|
|
|
src: ['*.png'],
|
|
|
|
dest: '<%= config.site %>/',
|
|
|
|
ext: '.png'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// dev server
|
|
|
|
connect: {
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 1337,
|
|
|
|
base: '_site'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// watch
|
|
|
|
watch: {
|
|
|
|
options: {
|
|
|
|
livereload: true
|
|
|
|
},
|
|
|
|
less: {
|
|
|
|
files: ['<%= config.src %>/<%= config.assets.less %>/*.less'],
|
|
|
|
tasks: ['less']
|
|
|
|
},
|
|
|
|
js: {
|
|
|
|
files: ['<%= config.src %>/<%= config.assets.js %>/*.js'],
|
|
|
|
tasks: ['uglify']
|
|
|
|
},
|
|
|
|
jekyll: {
|
|
|
|
files: [
|
|
|
|
'<%= config.src %>/*.html',
|
|
|
|
'<%= config.src %>/_includes/**',
|
2013-11-18 22:09:20 +01:00
|
|
|
'<%= config.src %>/_layouts/**',
|
|
|
|
'<%= config.src %>/_posts/**'
|
2013-11-18 01:08:13 +01:00
|
|
|
],
|
2013-11-18 22:09:20 +01:00
|
|
|
tasks: ['jekyll', 'less']
|
2013-11-18 01:08:13 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Deployment
|
|
|
|
rsync: {
|
|
|
|
options: {
|
|
|
|
args: ['--verbose'],
|
|
|
|
recursive: true,
|
|
|
|
syncDest: true,
|
|
|
|
compareMode: 'checksum',
|
|
|
|
ssh: true
|
|
|
|
},
|
|
|
|
production: {
|
|
|
|
options: {
|
|
|
|
src: '<%= config.site %>/',
|
|
|
|
dest: 'domains/kremalicious.com/html/',
|
|
|
|
host: 'kremalicious'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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', [
|
|
|
|
'watch'
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Dev server
|
|
|
|
grunt.registerTask('server', [
|
|
|
|
'jekyll',
|
|
|
|
'less',
|
|
|
|
'cmq',
|
|
|
|
'cssmin',
|
2013-11-18 22:09:20 +01:00
|
|
|
//'uglify',
|
2013-11-18 01:08:13 +01:00
|
|
|
'connect',
|
|
|
|
'watch'
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Production build
|
|
|
|
grunt.registerTask('build', [
|
|
|
|
'clean',
|
|
|
|
'jekyll',
|
|
|
|
'imagemin',
|
|
|
|
'less',
|
|
|
|
'cmq',
|
|
|
|
'cssmin',
|
|
|
|
'uglify'
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Deploy
|
|
|
|
grunt.registerTask('deploy', [
|
|
|
|
'rsync'
|
|
|
|
]);
|
|
|
|
|
|
|
|
};
|