forked from schteppe/cannon.js
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Gruntfile.js
86 lines (70 loc) · 2.46 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
var fs = require('fs')
module.exports = function(grunt) {
var bundlePath = "build/cannon.js",
minifiedBundlePath = "build/cannon.min.js";
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: '\n\n'
},
demo : {
src: ['src/demo/Demo.js'],
dest: 'build/cannon.demo.js'
},
},
browserify : {
cannon : {
src : ["src/Cannon.js"],
dest : bundlePath,
options : {
bundleOptions: {
standalone : "CANNON"
}
}
}
},
uglify : {
build : {
src : [bundlePath],
dest : minifiedBundlePath
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
outdir : "docs",
paths : ["./src/"],
},
}
},
nodeunit: {
all: ['test/**/*.js'],
},
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-browserify');
grunt.registerTask('default', ['test', 'concat', 'browserify', 'uglify']);
grunt.registerTask('test', ['nodeunit']);
grunt.registerTask('addDate','Adds the current date to the top of the built files',function(){
var text = '// ' + new Date().toUTCString() + '\n';
var dev = fs.readFileSync(bundlePath).toString();
var min = fs.readFileSync(minifiedBundlePath).toString();
fs.writeFileSync(bundlePath,text+"\n"+dev);
fs.writeFileSync(minifiedBundlePath,text+"\n"+min);
});
grunt.registerTask('addLicense','Adds the LICENSE to the top of the built files',function(){
var text = fs.readFileSync("LICENSE").toString();
var dev = fs.readFileSync(bundlePath).toString();
var min = fs.readFileSync(minifiedBundlePath).toString();
fs.writeFileSync(bundlePath,text+"\n"+dev);
fs.writeFileSync(minifiedBundlePath,text+"\n"+min);
});
};