-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
128 lines (120 loc) · 3.15 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jekyll_config: grunt.file.readYAML('_config.yml'),
sass: {
options: {
sourceMap: true,
includePaths: ['_sass',
'bower_components/bootstrap-sass/assets/stylesheets',
'bower_components/hint.css',
]
},
dist: {
files: {
'assets/css/main.css': 'css/main.scss'
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
sourceMap: true
},
build: {
src: [
'bower_components/waypoints/lib/jquery.waypoints.js',
'assets/js/main.js'
],
dest: 'assets/js/<%= pkg.name %>.min.js'
}
},
minjson: {
compile: {
files: {
// Minify one json file
'assets/lcc.min.geojson': 'assets/lcc_1.geojson',
}
}
},
watch: {
css: {
files: [
'./css/**/*.scss',
'./_sass/**/*.scss',
],
tasks: ['sass','jekyll'],
options: {
livereload: true,
},
},
scripts: {
files: ['./assets/**/*.js'],
tasks: ['uglify', 'jekyll'],
options: {},
},
html: {
files: [
'./_includes/**/*.html',
'./_layouts/**/*.html',
'./_posts/**/*.html',
'./_posts/**/*.md',
'./*.html',
'./*.md'
],
tasks: ['default'],
options: {},
},
data: {
files: [
'./_data/**/*.yml',
],
tasks: ['jekyll'],
options: {},
},
},
jekyll: { // Task
options: { // Universal options
bundleExec: true,
//src: '<%= app %>'
},
dist: { // Target
options: { // Target options
//dest: '<%= dist %>',
config: '_config.yml'
}
}
}
});
// Load the plugin that provides the "uglify" task.
//grunt.loadNpmTasks('grunt-sass');
//Generate index files for Jekyll categories
grunt.registerTask('category', 'Generate category indexes.', function() {
var jekyll = grunt.config('jekyll_config');
var cats = jekyll.prose.metadata._posts.find(function(itm) {
return itm.name === 'category';
});
var template = grunt.file.read('_category_idx_template.md');
if(grunt.file.isDir('categories')) {
grunt.file.delete('categories');
}
cats.field.options.forEach(function(itm) {
var data = {
title: itm.name,
link: itm.value,
icon: itm.icon,
description: itm.description,
resource: itm.resource ? true : false
};
content = grunt.template.process(template, {
data: data
});
grunt.file.write('./categories/' + itm.value + '.md', content);
grunt.log.writeln('Created the "'+ itm.value +'" category.');
});
});
// Default task(s).
grunt.registerTask('default', ['category','sass', 'uglify', 'minjson']);
};