-
Notifications
You must be signed in to change notification settings - Fork 10
/
Gruntfile.js
170 lines (152 loc) · 5.75 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
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib');
// grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask("default", ["server"]);
grunt.registerTask("server", ["handlebars", "connect"]);
grunt.registerTask("liveload", ["watch"]);
grunt.registerTask("release", ["clean", "handlebars", "requirejs", "concat", "copy"]);
/* if release-task supports grunt 0.4.0, use instead
/ grunt.registerTask("default", "clean lint jst requirejs concat");
/ grunt.registerTask("release", ["default", "min", "mincss"]);
*/
grunt.initConfig({
clean : ["dist/"],
lint : {
files : [
"build/config.js", "app/**/*.js"
]
},
copy: {
main: {
files: [
{cwd: 'dist/debug/', src: ['**'], dest: 'dist/release/', expand: true},
{cwd: 'assets/', src: ['**'], dest: 'dist/release/', expand: true},
{src: ['index.html'], dest: 'dist/release/'}
]
}
},
// The jshint option for scripturl is set to lax, because the anchor
// override inside main.js needs to test for them so as to not accidentally
// route.
jshint : {
options : {
scripturl : true
}
},
handlebars : {
compile : {
options : {
namespace : "JST",
processName : function (filePath) {
return getSimpleFileName(filePath);
},
processPartialName : function (filePath) { // input: templates/_header.handlebar
return getSimpleFileName(filePath);
},
partialRegex : /\.template_partial$/
},
files : {
"dist/debug/handlebars_packaged.js" : 'app/templates/**/*.template*'
}
}
},
watch : {
files : ['app/templates/**/*.template*'], // 'app/**/*.less',
tasks : 'handlebars'
},
mincss : {
"dist/release/index.css" : [
"assets/css/h5bp.css"
]
},
min : {
"dist/release/require.js" : [
"dist/debug/require.js"
]
},
connect: {
server: {
options: {
port: 9001,
base: '.',
keepalive : true
}
}
},
requirejs : {
compile : {
options : {
baseUrl : "app/",
mainConfigFile : "app/config.js",
out : "dist/debug/require.js",
name : "config",
// Do not wrap everything in an IIFE
wrap : false
}
}
},
qunit : {
all : ["test/qunit/*.html"]
}
// The concatenate task is used here to merge the almond require/define
// shim and the templates into the application code. It's named
// dist/debug/require.js, because we want to only load one script file in
// index.html.
,concat : {
"dist/debug/require.js" : [
"assets/js/libs/almond.js",
"dist/debug/templates.js",
"dist/debug/require.js"
],
"dist/debug/handlebars_packaged.js" : [
"app/handlebars_helpers.js",
"app/alltemplates.js"
]
}
/*
With the upgrade to grunt 0.4.0, the grunt-release task is not supported, yet.
With 0.4.0, the release-task was replaced by the copy- and connect-task,
which slows down the development process of server reloading.
server : {
files : {
"favicon.ico" : "favicon.ico"
},
debug : {
files : {
"favicon.ico" : "favicon.ico"
},
folders : {
"app" : "dist/debug",
"assets/js/libs" : "dist/debug"
}
},
release : {
host : "0.0.0.0",
port : process.env.PORT || 8000,
files : {
"favicon.ico" : "favicon.ico"
},
folders : {
"app" : "dist/release",
"assets/js/libs" : "dist/release",
"assets/css" : "dist/release"
}
}
},
*/
}
);
var getSimpleFileName = function (fullFilePath) {
var fileName = fullFilePath.substring(fullFilePath.lastIndexOf('/') + 1);
return fileName.substring(0, fileName.indexOf('.'));
};
}
;