-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
173 lines (148 loc) · 5.22 KB
/
Gruntfile.js
File metadata and controls
173 lines (148 loc) · 5.22 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* sandbox
*
* John O'Donnell
* https://github.com/john/sandbox
*
* Copyright (c) 2014
* Licensed under the MIT license.
*/
module.exports = function(grunt) {
'use strict';
// 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'),
bootstrap: '<%= vendor %>/bootstrap',
// Before generating any new files, remove files from previous build.
clean: {
example: ['<%= site.dest %>/*.html'],
// Delete this target after first run!!!
once: ['<%= site.theme %>/bootstrap/{var*,mix*,util*}.less']
},
// Lint JavaScript
jshint: {
all: ['Gruntfile.js', 'templates/helpers/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
// 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 %>',
// navigation
navigation: {
'main': {},
'footer': {}
}
},
example: {
//files: {'<%= site.dest %>/': ['<%= site.templates %>/*.hbs']}
expand: true, // use extra file management features
cwd: 'templates/pages/', // we're telling grunt to use pages dir as our copy root
src: '**/*.hbs',
dest: '<%= site.dest %>/' // whatevers in docs is now in here
}
},
// Compile LESS to CSS
less: {
options: {
vendor: 'vendor',
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: ['{util*,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/'},
]
}
},
watch: {
all: {
files: ['<%= jshint.all %>'],
tasks: ['jshint', 'nodeunit']
},
site: {
files: ['Gruntfile.js', '<%= less.options.paths %>/*.less', 'templates/**/*.hbs'],
tasks: ['design']
}
},
connect: {
server: {
options: {
port: 9001,
base: '_gh_pages'
}
}
}
});
// 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-readme');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-contrib-connect'); // start webserver
// 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']);
grunt.registerTask('docs', ['readme', 'sync']);
grunt.registerTask('develop', ['connect', 'design']);
// Delete this conditional logic after first run.
if(!grunt.file.exists('_gh_pages_/assets/fonts') && !grunt.file.exists('_gh_pages_/assets/js')) {
grunt.registerTask('default', ['setup', 'clean', 'jshint', 'copy:assets', 'assemble', 'less', 'docs']);
} else {
// Use this going forward.
grunt.registerTask('default', ['clean', 'jshint', 'copy:assets', 'assemble', 'less', 'docs']);
}
};