-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
145 lines (121 loc) · 4.29 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* boilerplate
* https://github.com/assemble/boilerplate
* Copyright (c) 2013
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
// Delete after first run
if(!grunt.file.exists('vendor/bootstrap')) {
grunt.fail.fatal('>> Please run "bower install" before continuing.');
}
// Project configuration.
grunt.initConfig({
// Project metadata
pkg : grunt.file.readJSON('package.json'),
vendor: grunt.file.readJSON('.bowerrc').directory,
site : grunt.file.readYAML('_config.yml'),
// Aliases
bootstrap: '<%= vendor %>/bootstrap',
// Build HTML from templates and data
assemble: {
options: {
flatten: true,
production: false,
assets: '<%= site.assets %>',
postprocess: require('pretty'),
// Metadata
pkg: '<%= pkg %>',
site: '<%= site %>',
data: ['<%= site.data %>'],
// Templates
partials: '<%= site.includes %>',
layoutdir: '<%= site.layouts %>',
layout: '<%= site.layout %>',
// Extensions
helpers: '<%= site.helpers %>',
plugins: '<%= site.plugins %>'
},
example: {
files: {'<%= site.dest %>/': ['<%= site.templates %>/*.hbs']}
}
},
// Compile LESS to CSS
less: {
options: {
paths: [
'<%= site.theme %>',
'<%= site.theme %>/bootstrap',
'<%= site.theme %>/components',
'<%= site.theme %>/utils'
],
},
site: {
src: ['<%= site.theme %>/site.less'],
dest: '<%= site.assets %>/css/site.css'
}
},
// Copy Bootstrap's assets to site assets
copy: {
// Delete this target after first run!!! Afterwards you'll need to
// decide on a strategy for adding javascripts, fonts etc.
once: {
files: [
{expand: true, cwd: '<%= bootstrap %>/less', src: ['*', '!{var*,mix*,util*}'], dest: '<%= site.theme %>/bootstrap/'},
{expand: true, cwd: '<%= bootstrap %>/less', src: ['{var*,mix*}.less'], dest: '<%= site.theme %>/utils'},
{expand: true, cwd: '<%= bootstrap %>/less', src: ['variables.less'], dest: '<%= site.theme %>/'},
{expand: true, cwd: 'node_modules/showup', src: ['showup.js'], dest: '<%= site.assets %>/js/'},
{expand: true, cwd: 'node_modules/showup', src: ['showup.css'], dest: '<%= site.theme %>/components/', ext: '.less'},
]
},
// Keep this target as a getting started point
assets: {
files: [
{expand: true, cwd: '<%= bootstrap %>/dist/fonts', src: ['*.*'], dest: '<%= site.assets %>/fonts/'},
{expand: true, cwd: '<%= bootstrap %>/dist/js', src: ['*.*'], dest: '<%= site.assets %>/js/'},
]
}
},
// Lint JavaScript
jshint: {
all: ['Gruntfile.js', 'templates/helpers/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
// Before generating any new files,
// remove any previously-created files.
clean: {
example: ['<%= site.dest %>/*.html'],
// Delete this target after first run!!!
once: ['<%= site.theme %>/bootstrap/{var*,mix*,util*}.less']
},
watch: {
all: {
files: ['<%= jshint.all %>'],
tasks: ['jshint', 'nodeunit']
},
site: {
files: ['Gruntfile.js', '<%= less.options.paths %>/*.less', 'templates/**/*.hbs'],
tasks: ['design']
}
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-verb');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('assemble');
// Run this task once, then delete it as well as all of the "once" targets.
grunt.registerTask('setup', ['copy:once', 'clean:once']);
// Build HTML, compile LESS and watch for changes. You must first run "bower install"
// or install Bootstrap to the "vendor" directory before running this command.
grunt.registerTask('design', ['clean', 'assemble', 'less:site', 'watch:site']);
// Default tasks to be run.
grunt.registerTask('default', ['clean', 'jshint', 'copy:assets', 'assemble', 'less']);
};