forked from normanzb/chuanr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
74 lines (67 loc) · 2.45 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
/*global module:false*/
module.exports = function(grunt) {
var SPACE_NAME = 'Chuanr';
var EXT_JS = '.js';
var EXT_JS_MIN = '.min' + EXT_JS;
var FILE_NAME_OUT_MAX = SPACE_NAME + EXT_JS;
var FILE_NAME_OUT_MIN = SPACE_NAME + EXT_JS_MIN;
var FILE_NAME_ENTRY = SPACE_NAME;
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-bumpup");
grunt.loadNpmTasks("grunt-tagrelease");
grunt.config.init({
requirejs : {
dist : {
options : {
baseUrl: './src',
name: '../lib/amdshim/amdshim.embed',
include: FILE_NAME_ENTRY,
out: FILE_NAME_OUT_MAX,
wrap: {
start:
"(function() { \n" +
"var global = new Function('return this')();" +
"var myDefine = (function(factory){ " +
"var ret = factory();" +
"typeof module != 'undefined' && (module.exports = ret);" +
"(function(define){define && define(function(){return ret;});})(global.define);" +
"global." + SPACE_NAME + " = ret; });",
end:
"myDefine(function() { return require('" + SPACE_NAME + "'); }); \n" +
"}());"
},
pragmas: {
release: true
},
optimize : "none"
}
}
},
uglify : {
dist : {
src : [ FILE_NAME_OUT_MAX ],
dest : FILE_NAME_OUT_MIN
}
},
bumpup: {
files: ['package.json', 'bower.json']
},
tagrelease: {
file: 'package.json',
commit: true,
message: 'Release %version%',
prefix: '',
annotate: false
}
});
grunt.registerTask("dist", "requirejs:dist uglify".split(' '));
grunt.registerTask("default", "dist".split(' '));
grunt.registerTask("release", function (type) {
grunt.task.run('dist');
if (type != null && type != false){
grunt.task.run('bumpup:' + type);
grunt.task.run('tagrelease');
}
});
};