forked from Leftium/todo.html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
86 lines (74 loc) · 2.39 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
release: {
options: {
appDir: "src",
baseUrl: "js",
dir: "built/requirejs",
uglify: {
ascii_only: true
},
preserveLicenseComments: false,
paths: { node_modules: '../../node_modules' },
modules: [
{
name: "main"
}
]
}
},
debug: {
options: {
appDir: "src",
baseUrl: "js",
dir: "built/requirejs",
optimize: 'none',
uglify: {
ascii_only: true
},
preserveLicenseComments: false,
paths: { node_modules: '../../node_modules' },
modules: [
{
name: "main"
}
]
}
}
},
smoosher: {
files: {
src: 'built/requirejs/todo.html',
dest: 'built/smoosher/todo.html'
},
},
oneliner: {
files: {
src: 'built/smoosher/todo.html',
dest: 'todo.html'
}
}
});
grunt.loadNpmTasks('grunt-html-smoosher');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerMultiTask('oneliner', 'into a single line', function() {
this.files.forEach(function(filePair) {
// Check that the source file exists
if(filePair.src.length === 0) { return; }
var text = grunt.file.read(filePair.src);
var regex = /([\s\S]*)(^!!WARNING!! Do not edit this line.[\s\S]*$)/m
var matches = text.match(regex);
var todos = matches[1];
var html = matches[2];
html = html.replace(/\n/g, '');
grunt.file.write(filePair.dest, todos + html);
});
});
// Default task(s).
grunt.registerTask('default', ['requirejs:release', 'smoosher', 'oneliner']);
// More legible; don't compress
grunt.registerTask('debug', ['requirejs:debug', 'smoosher']);
};