/
Gruntfile.js
75 lines (62 loc) · 1.75 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
/*
* assemble-swig-example
* https://github.com/assemble/assemble-swig-example
*
* Copyright (c) 2013 Jon Schlinkert, Brian Woodward, contributors
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
grunt.util._.mixin({
read: function(src) {
grunt.file.read(require('path').join('src/content', src));
}
});
var pretty = require('pretty');
// Project configuration.
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
site: grunt.file.readYAML('_config.yml'),
// Lint JavaScript
jshint: {
all: ['Gruntfile.js', 'src/helpers/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
// Build HTML from templates and data
assemble: {
options: {
engine: 'swig',
// Register Swig extensions
helpers: ['src/extensions/*.js', 'src/extensions/filters/*.js'],
// Templates and data
data: ['src/data/*.{json,yml}'],
partials: ['src/includes/*.swig'],
layoutdir: 'src/layouts',
layoutext: '.swig',
layout: 'default',
flatten: true,
site: '<%= site %>',
assets: '<%= site.dest %>/assets',
postprocess: pretty
},
pages: {
src: ['src/*.swig'],
dest: '<%= site.dest %>/'
}
},
// Before generating any new files,
// remove files from previous build.
clean: {
example: ['<%= site.dest %>/*.html']
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-verb');
// Default tasks to be run.
grunt.registerTask('default', ['clean', 'jshint', 'assemble']);
};