-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathGruntfile.js
177 lines (154 loc) · 4.85 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
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
174
175
176
177
/*
* assemble-bootstrap
* http://github.com/assemble/assemble-bootstrap
*
* Copyright (c) 2013 Jon Schlinkert
* MIT License
*/
"use strict";
module.exports = function(grunt) {
var pretty = require('pretty');
var vendor = grunt.file.readJSON('.bowerrc').directory;
if(!grunt.file.exists(vendor + '/bootstrap/_config.yml')) {
grunt.fail.fatal('>> Please run "bower install" before continuing.');
}
// Project configuration.
grunt.initConfig({
// Project metadata
pkg : grunt.file.readJSON('package.json'),
site : grunt.file.readYAML('_config.yml'),
vendor: vendor,
// Convenience
bootstrap: '<%= vendor %>/bootstrap',
// Run Bootstrap's own Gruntfile.
subgrunt: {
test: {
options: {task: 'test'},
src: ['<%= bootstrap %>']
},
js: {
options: {task: 'concat'},
src: ['<%= bootstrap %>']
},
css: {
options: {task: 'less'},
src: ['<%= bootstrap %>']
},
dist: {
options: {task: 'dist'},
src: ['<%= bootstrap %>']
},
all: {
options: {task: 'default'},
src: ['<%= bootstrap %>']
}
},
// Regex for refactor task.
replacements: require('./tasks/replacements'),
// Refactor Liquid to Handlebars so we can
// build with Assemble instead of Jekyll
frep: {
bootstrap: {
options: {
replacements: '<%= replacements.bootstrap %>'
},
files: [
{expand: true, cwd: '<%= bootstrap %>', src: ['*.html', '_layouts/*.html', '_includes/*.html'], dest: 'templates/', ext: '.hbs'}
]
},
examples: {
options: {
replacements: '<%= replacements.examples %>'
},
files: [
{expand: true, filter: 'isFile', cwd: '<%= bootstrap %>/examples', src: ['{*,**}/*.html'], dest: '<%= site.dest %>/examples/'}
]
}
},
assemble: {
options: {
flatten: true,
assets: '<%= site.assets %>',
data: '<%= site.data %>/*.{json,yml}',
// Metadata
site: '<%= site %>',
// Templates
partials: '<%= site.includes %>',
layoutdir: '<%= site.layouts %>',
layout: '<%= site.layout %>',
},
site: {
src: ['templates/*.hbs'],
dest: '<%= site.dest %>/'
}
},
// 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: {
vendor: {
files: {
'<%= site.assets %>/js/highlight.js': ['<%= vendor %>/highlightjs/highlight.pack.js'],
'<%= site.assets %>/css/github.css': ['<%= vendor %>/highlightjs/styles/github.css']
}
},
assets: {
files: [
{expand: true, cwd: '<%= bootstrap %>/examples', src: ['**/*.css', '**/*.{jpg,png,gif}'], dest: '<%= site.dest %>/examples/'},
{expand: true, cwd: '<%= bootstrap %>/docs-assets', src: ['**'], dest: '<%= site.assets %>/'},
{expand: true, cwd: '<%= bootstrap %>/_data', src: ['**'], dest: '<%= site.data %>/'},
{expand: true, cwd: '<%= bootstrap %>/dist', src: ['**'], dest: '<%= site.assets %>/'},
]
},
update: {
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 %>/'},
]
}
},
clean: {
dist: ['<%= site.dest %>/**/*', '!<%= site.dest %>/.{git,gitignore}'],
update: ['<%= site.theme %>/bootstrap/{var*,mix*,util*}.less']
}
});
grunt.config.set('site.description', 'Generated by http://assemble.io');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-frep');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.loadNpmTasks('grunt-verb');
// Load local "Subgrunt" task to run Bootstrap's Gruntfile.
grunt.loadTasks('tasks');
// Tests task.
grunt.registerTask('test', ['subgrunt:test']);
grunt.registerTask('dev', ['clean', 'frep', 'assemble']);
grunt.registerTask('update', ['copy:update', 'clean:update']);
// Default task to be run with the "grunt" command.
grunt.registerTask('default', [
'clean',
'subgrunt:js',
'subgrunt:css',
'copy',
'frep',
'assemble',
'less',
'sync'
]);
};