-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
129 lines (116 loc) · 3.07 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
all: ['build/*'],
// remove unneeded, intermediate build files:
combined_css: ['build/css/combined.css'],
pages: ['build/pages/']
},
copy: {
img: {
expand: true,
cwd: 'src/img/',
src: '**',
dest: 'build/img/',
filter: 'isFile'
},
html: {
expand: true,
cwd: 'build/pages/',
src: '**',
dest: 'build/',
flatten: true,
filter: 'isFile',
rename: function prettify_url(dest, src) {
// Convert HTML files to folders of the same name with just an 'index.html' inside.
// For example: 'contact.html' -> 'build/contact/index.html'
// Exception: 'home.html' -> 'build/index.html'
// This is for pretty URLs.
var final_dest = dest + '/' + src.substr(0, src.indexOf('.html')) + '/index.html';
if (src === 'home.html') {
final_dest = 'build/index.html'
}
return final_dest;
}
}
},
concat: {
css: {
src: [
'src/css/normalize.min.css',
'src/css/main.css',
'src/css/responsive.css'
],
dest: 'build/css/combined.css'
}
},
cssmin: {
all: {
src: 'build/css/combined.css',
dest: 'build/css/style.min.css'
},
},
uglify: {
release: {
files: {
'build/js/main.min.js': ['src/js/main.js']
}
},
debug: {
options: {
beautify: {
beautify: true
}
},
files: {
'build/js/main.min.js': ['src/js/main.js']
}
},
},
assemble: {
options: {
layout: ['src/views/layouts/main.hbs'],
flatten: true
},
pages: {
files: {
'build/pages/': ['src/views/pages/*.hbs']
}
}
},
watch: {
html: {
files: ['src/views/**/*.hbs'],
tasks: ['html']
},
css: {
files: ['src/css/**/*.css'],
tasks: ['css']
},
js: {
files: ['src/js/**/*.js'],
tasks: ['js']
},
img: {
files: ['src/img/**/*.jpg', 'src/img/**/*.png', 'src/img/**/*.gif','src/img/**/*.ico'],
tasks: ['img']
}
}
});
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
// Run these like "$ grunt html"
grunt.registerTask('html', ['assemble', 'copy:html', 'clean:pages']);
grunt.registerTask('css', ['concat:css', 'cssmin', 'clean:combined_css']);
grunt.registerTask('js', ['uglify:release']);
grunt.registerTask('img', ['copy:img']);
// Run this with just "$ grunt":
grunt.registerTask('default', ['html', 'css', 'js', 'img']);
};