forked from joelrbrandt/mockfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
122 lines (108 loc) · 3.61 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
/* jshint browser: false, node: true */
module.exports = function (grunt) {
"use strict";
var swapHTMLIncludes = function (content) {
var lines = content.split("\n"),
devStart = -1, devEnd = -1, deployStart = -1, deployEnd = -1,
i;
for (i = 0; i < lines.length; ++i) {
if (lines[i].indexOf("BEGIN devincludes") >= 0) {
devStart = i;
}
if (lines[i].indexOf("END devincludes") >= 0) {
devEnd = i;
}
if (devStart >= 0 && devEnd >= 0) {
lines.splice(devStart, devEnd - devStart + 1);
break;
}
}
for (i = 0; i < lines.length; ++i) {
if (lines[i].indexOf("BEGIN deployincludes") >= 0) {
deployStart = i;
}
if (lines[i].indexOf("END deployincludes") >= 0) {
deployEnd = i;
}
if (deployStart >= 0 && deployEnd >= 0) {
lines.splice(deployStart, 1);
lines.splice(deployEnd - 1, 1);
break;
}
}
return lines.join("\n");
};
grunt.initConfig({
jshint : {
options : {
jshintrc : ".jshintrc"
},
all : [
"*.js",
"package.json",
"bower.json",
".jshintrc",
".jscsrc",
"js/**/*.js"
]
},
jscs: {
src: "<%= jshint.all %>",
options: {
config: ".jscsrc"
}
},
requirejs: {
compile: {
options: {
baseUrl: "js",
mainConfigFile: "js/main.js",
paths: {
"jQuery" : "../bower_components/jquery/dist/jquery.min",
"bootstrap" : "../bower_components/bootstrap/dist/js/bootstrap.min",
"requirejs" : "../bower_components/requirejs/require"
},
name: "main",
out: "build/main.js",
optimize: "none",
include: ["jQuery", "bootstrap", "requirejs"]
}
}
},
copy: {
css : {
files : [
{
src: "bower_components/bootstrap/dist/css/bootstrap.min.css",
dest: "build/bootstrap.min.css"
},
{
src: "bower_components/bootstrap/dist/css/bootstrap-theme.min.css",
dest: "build/bootstrap-theme.min.css"
},
{
src: "bower_components/codemirror/lib/codemirror.css",
dest: "build/codemirror.css"
},
{
src: "html/style.css",
dest: "build/style.css"
}
]
},
html : {
src: "html/index.html",
dest: "build/index.html",
options: {
process: swapHTMLIncludes
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-jscs-checker");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.registerTask("default", ["jshint", "jscs"]);
grunt.registerTask("build", ["copy:css", "copy:html", "requirejs"]);
};