-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
182 lines (162 loc) · 4.56 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
178
179
180
181
182
/*
* Phantom-Development
*
* Marc Roberts
* https://github.com/mroberts46/Phantom-Development
*
* Copyright (c) 2014
* Licensed under the MIT license.
*/
module.exports = function(grunt) {
'use strict';
// 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']
},
// Lint JavaScript
jshint: {
all: ['Gruntfile.js', 'templates/helpers/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
// Build HTML from templates and data
assemble: {
options: {
flatten: true,
production: true,
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: {
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: {
// 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/'},
]
}
},
autoprefixer: {
options: {
browers: ['last 2 versions', 'ie 8', 'ie 9'],
cascade: true
},
files: {
expand: true,
flatten: true,
src: '<%= less.options.paths %>/*.less',
dest: '<%= site.theme %>/site.less'
}
},
imagemin: {
images: {
options: {
optimizationLevel: 6,
svgoPlugins: [{ removeViewbox: false}]
},
files: [{
expand: true,
cwd: 'resources/',
src: ['**/*.{png,,gif,jpg}'],
dest: '<%= site.assets %>/img/'
}]
}
},
svgstore: {
options: {
prefix: 'svg-',
includedemo: true
},
files: {
expand: true,
cwd: 'resources/',
src: 'svg/*.svg',
dest: '<%= site.assets/svg/'
}
},
connect: {
server: {
options: {
port: 4000,
hostname: 'localhost',
base: '<%= site.dest %>',
livereload: true,
open: true
}
}
},
watch: {
options: {
reload: true,
livereload: true,
event: 'all'
},
all: {
files: ['<%= jshint.all %>'],
tasks: ['jshint', 'nodeunit']
},
site: {
files: ['Gruntfile.js', '<%= less.options.paths %>/*.less', 'templates/**/*.hbs']
}
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-readme');
grunt.loadNpmTasks('grunt-svgstore');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('assemble');
// 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']);
// Use this going forward.
grunt.registerTask('default', ['clean','jshint','copy','assemble','imagemin','svgstore','autoprefixer','less','docs','connect','watch:site']);
};