-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
81 lines (78 loc) · 2.35 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
module.exports = function(grunt) {
grunt.initConfig({
htmlmin: {
html: {
options: {
removeComments: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeTagWhitespace: true,
continueOnParseError: true,
keepClosingSlash: true
},
files: {
"build/1-sheet.html": "src/1-sheet.html",
"build/2-templates.html": "src/2-templates.html"
}
}
},
replace: {
html: {
options: {
patterns: [
{match: "> <", replacement: "><"}
],
usePrefix: false,
silent: true
},
files: [
{expand: true, flatten: true, src: ["build/1-sheet.html", "build/2-templates.html"], dest: "build"}
]
},
js: {
options: {
patterns: [
{match: new RegExp("<!--.*-->", "gi"), replacement: ""}, // html inline comments
{match: new RegExp("^\\s+", "gim"), replacement: ""}, // whitespaces at line start
{match: new RegExp("\\s+$", "gim"), replacement: ""}, // whitespaces at line end
{match: new RegExp("^(//.*)?$", "gim"), replacement: ""}, // inline comments at line start
{match: new RegExp("(\{|;|,|\\))\\s*//.*$", "gim"), replacement: "$1"}, // inline comments after statement
{match: new RegExp("(\\w)\\s+//.*$", "gim"), replacement: "$1"}, // inline comments after word
{match: new RegExp("/\\*(.|\\r|\\n)*\\*/", "gim"), replacement: ""}, // multiline comments
{match: new RegExp("(\\r|\\n)", "gi"), replacement: ""} // carriage returns and line feeds
],
usePrefix: false,
silent: true
},
files: [
{expand: true, flatten: true, src: ["src/3-worker.js"], dest: "build"}
]
},
translation: {
options: {
patterns: [
{match: new RegExp("\t//.*", "gi"), replacement: ""},
{match: new RegExp("(\r\n)(\r\n)+", "gi"), replacement: "$1"}
],
usePrefix: false,
silent: true
},
files: [
{src: ["src/0-translation.json"], dest: "translation.json"}
]
}
},
concat: {
html: {
src: ["build/1-sheet.html", "build/2-templates.html", "build/3-worker.js"],
dest: "stalker.html"
}
}
});
// Load the plugin that provides the tasks
grunt.loadNpmTasks("grunt-contrib-htmlmin");
grunt.loadNpmTasks("grunt-replace");
grunt.loadNpmTasks("grunt-contrib-concat");
// Default tasks
grunt.registerTask("default", ["htmlmin", "replace", "concat"]);
};