forked from twitter/opensource-website
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
191 lines (191 loc) · 4.86 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
183
184
185
186
187
188
189
190
191
module.exports = function(grunt) {
"use strict";
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
files: [{
expand: true,
flatten: true,
src: ['src/css/Alef-Webfont/*'],
dest: 'dest/css/Alef-Webfont'
}, {
expand: true,
cwd: 'src',
src: ['css/font-awesome-4.0.3/**'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['css/favicon.ico*'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['all-issues/**'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['main-page/**'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['visualizations/**'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['templates/**'],
dest: 'dest/'
}, {
expand: true,
cwd: 'src',
src: ['data/**'],
dest: 'dest/'
}]
}
},
uglify: { // uglify all the js - from src to dest
target: {
options: {
mangle: false,
dead_code: false,
compress: {
drop_console: true
}
},
files: [{
expand: true,
cwd: 'src',
src: '**/*.js',
dest: 'dest'
}]
}
},
cssmin: {
combine: {
files: {
'dest/css/style.css': ["src/css/filesPiChart.css",
"src/css/headerStyle.css", "src/css/index.css", "src/css/reset.css",
"src/css/style.css"
]
},
keepSpecialComments: "0"
}
},
dom_munger: { // Remove all script link tags from src/index.html and copy it to root folder.
removeScriptsAndLink: {
options: {
remove: 'script,link'
},
src: 'src/index.html',
dest: 'index.html'
},
addFavIcon: { // Add favIcon
options: {
append: {
selector: 'head',
html: '<link rel="shortcut icon" href="dest/css/favicon.ico">'
},
},
src: 'index.html',
dest: 'index.html'
}
},
bowerInstall: { // Add bower depts to index.html
target: {
src: 'index.html'
}
},
tags: { // Inject the minifyed JavaScript and css to index.html
injectJavaScript: {
src: ['dest/eKnightsData.js', 'dest/small_repos.js', 'dest/config.js',
'dest/hebUtill.js', 'dest/commentsHandler.js', 'dest/filters.js',
'dest/arrayUtill.js', 'dest/issuesLoader.js', 'dest/main.js',
'dest/visualizations/piVisualization/pieChartService.js',
'dest/visualizations/piVisualization/ghPiVisualization.js',
'dest/visualizations/piVisualization/piChartCtrl.js',
'dest/all-issues/allIssuesCtrl.js', 'dest/eKnight.js',
'update/modules/Repository.js', 'dest/main-page/filters.js',
'dest/main-page/index.js'
],
options: {
scriptTemplate: '<script src="{{ path }}"></script>',
openTag: '<!-- start template js -->',
closeTag: '<!-- end template js -->'
},
dest: 'index.html'
},
injectCss: {
src: ['dest/css/style.css', 'dest/css/Alef-Webfont/stylesheet.css',
'dest/css/font-awesome-4.0.3/css/font-awesome.min.css'
],
options: {
linkTemplate: '<link rel="stylesheet" type="text/css" href="{{ path }}"/>',
openTag: '<!-- start template css -->',
closeTag: '<!-- end template css -->'
},
dest: 'index.html'
}
},
'file-creator': { // Create config file
"basic": {
"dest/config.js": function(fs, fd, done) {
fs.writeSync(fd,
'var CONFIG = {PATH: "dest/",relativizePath: function(oldPath) {return CONFIG.PATH + oldPath;}};'
);
done();
}
}
},
lineremover: { // Remove empty lines
noOptions: {
files: {
'index.html': 'index.html'
}
}
},
prettify: { // Prettify index.html
one: {
src: 'index.html',
dest: 'index.html'
}
},
jsdoc: {
dist: {
src: ['src/*', 'test/*.js'],
options: {
destination: 'doc',
recurse: true
}
}
}
});
// Load the plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-bower-install');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-script-link-tags');
grunt.loadNpmTasks('grunt-dom-munger');
grunt.loadNpmTasks('grunt-file-creator');
grunt.loadNpmTasks('grunt-line-remover');
grunt.loadNpmTasks('grunt-prettify');
grunt.registerTask('init',
'Compiles all of the assets and copies the files to the build directory.\n' +
'Generating documentation in from the source code comments.', ['copy',
'uglify', 'jsdoc', 'dom_munger', 'bowerInstall', 'cssmin', 'tags',
'file-creator', 'lineremover', 'prettify'
]);
// Default task(s).
grunt.registerTask('default',
'Compiles all of the assets and copies the files to the build directory.', [
'copy', 'uglify', 'dom_munger', 'bowerInstall', 'cssmin', 'tags',
'file-creator', 'lineremover', 'prettify'
]);
grunt.registerTask('doc',
'Generating documentation in from the source code comments.', ['jsdoc']);
};