-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathGruntfile.js
120 lines (105 loc) · 3.69 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
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-uglify");
// Print a timestamp (useful for when watching)
grunt.registerTask("timestamp", function() {
grunt.log.subhead(Date());
});
/**
* Project configuration.
*/
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
banner:
'/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n */\n',
src: {
src_js: ['lib/*.js'],
test_js: ['test/test-*.js'],
demos: ['test/*.html']
},
/**
* JS Uglify
*/
uglify: {
dist: {
files: {
'./dist/js-2dmath-browser.min.js': ['./dist/js-2dmath-browser.js']
}
}
},
watch: {
scripts: {
files: ['lib/*.js', 'lib/*/*.js', '*.js', 'test/*.js'],
tasks: ['dist'],
options: {
debounceDelay: 250
},
},
}
}); // end config
grunt.task.registerTask('documentation', 'Generate debug files', function() {
require("./dist.js");
});
var argumentify = require('argumentify'),
argumentify_validators = {
Vec2: {
check: argumentify.check.ArrayOfNumbers(2),
message: "invalid Vec2 %var-name%"
},
Matrix23: {
check: argumentify.check.ArrayOfNumbers(6),
message: "invalid Matrix23 %var-name%"
},
Matrix22: {
check: argumentify.check.ArrayOfNumbers(4),
message: "invalid Matrix22 %var-name%"
},
AABB2: {
check: argumentify.check.ArrayOfNumbers(4),
message: "invalid AABB2 %var-name%"
},
Rectangle: {
check: argumentify.check.MultiArrayOfNumbers(2, 2),
message: "invalid Rectangle %var-name%"
},
Triangle: {
check: argumentify.check.MultiArrayOfNumbers(3, 2),
message: "invalid Traingle %var-name%"
}
};
grunt.task.registerTask('browserify:debug', 'Generate debug files', function() {
var done = this.async(),
fs = require('fs'),
output_stream = fs.createWriteStream('debug/js-2dmath-browser-debug.js');
argumentify.verbose();
argumentify.customValidators(argumentify_validators);
require('browserify')()
.require('./index.js', {expose: "js-2dmath"})
.transform('argumentify')
.bundle({
debug: true
})
.pipe(output_stream);
output_stream.on("close", function() {
grunt.log.ok("work done");
done();
});
});
grunt.task.registerTask('browserify:dist', 'Generate debug files', function() {
var done = this.async(),
browserify = require('browserify'),
fs = require('fs'),
stream;
require('browserify')()
.require('./index.js', {expose: "js-2dmath"})
//.transform('funlinify')
.bundle()
.pipe(fs.createWriteStream('dist/js-2dmath-browser.js'))
.on("close", function() {
done();
});
});
grunt.registerTask('dist', ['browserify:dist', 'browserify:debug', "uglify:dist"]);
};