-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathGruntfile.js
executable file
·102 lines (90 loc) · 2.64 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
module.exports = function (grunt) {
grunt.initConfig({
ts: {
// Note: this seems to be not working well under grunt-ts,
// giving a tsc warning about use of the 'out' option
// (which is not present in tsconfig.json) and stopping compilation.
default : {
tsconfig: "static/tsconfig.json",
options: {
rootDir: "static",
},
},
},
exec: {
// This, however, works well with tsc 5.7.2
tsc: {
cwd: "static",
command: "tsc",
stdout: true,
stderr: true
}
},
uglify: {
explo_js: {
options: {
sourceMap: true // Add source maps
},
src: "static/built/explo.js",
dest: "static/built/explo.min.js"
}
},
less: {
development: {
files: {
"static/skrafl-explo.css": ["static/skrafl-explo.less"]
},
options: {
}
},
production: {
files: {
"static/skrafl-explo.css": ["static/skrafl-explo.less"]
},
options: {
cleancss: true
}
}
},
clean: {
built: ["static/built/*"]
},
watch: {
options: {
spawn: false,
interrupt: true, // Interrupt previous tasks when new changes occur
atBegin: true // Run tasks when watch starts
},
ts: {
files: ["static/src/*.ts"],
tasks: ["ts"],
options: { spawn: false }
},
uglify_explo: {
files: ["static/built/explo.js"],
tasks: ["uglify:explo_js"],
options: { spawn: false }
},
less: {
files: ["static/*.less"],
tasks: ["less:development", "less:production"],
options: { spawn: false }
},
configFiles: {
files: "Gruntfile.js"
}
}
});
// Load Grunt tasks declared in the package.json file
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.registerTask("default", ["watch"]);
grunt.registerTask("make", ["clean", "exec:tsc", "uglify", "less"]);
// On watch events configure jshint:all to only run on changed file
grunt.event.on("watch", function(action, filepath) {
console.log("watch: " + filepath);
/*
if (startsWith(filepath, "static/js/") || startsWith(filepath, "static\\js\\"))
grunt.config("jshint.all.src", [ filepath ]);
*/
});
};