-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
107 lines (102 loc) · 2.92 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
module.exports = function(grunt) {
'use strict';
var RE_USE_STRICT_STATEMENT = /(^|\n)[ \t]*('use strict'|"use strict");?\s*/g,
RE_CONSOLE_METHODS = /console.[\w]+\(.*?(\w*\(.*\))*\);/g,
BANNER_TEMPLATE_STRING = '/*! <%= pkg.name %> - v<%= pkg.version %> ( <%= grunt.template.today("yyyy-mm-dd") %> ) - <%= pkg.license %> */',
BUILD_ORDERED_LIST = [
'src/define_class.js',
'src/trait/*.js',
'src/router.js',
'src/view.js',
'src/model.js',
'src/collection.js',
'src/layout.js',
'src/component.js',
'src/export.js'
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
stripBanners: false,
banner: [BANNER_TEMPLATE_STRING,
'(function(window) {',
'',
'"use strict";',
'',
''].join('\n'),
footer: ['',
'})(this);'].join('\n')
},
dist: {
src: BUILD_ORDERED_LIST,
dest: 'dist/phalanx.js',
options: {
process: function(content) {
return content.replace(RE_USE_STRICT_STATEMENT, '$1').replace(RE_CONSOLE_METHODS, '');
}
}
},
debug: {
src: BUILD_ORDERED_LIST,
dest: 'dist/phalanx.debug.js',
options: {
process: function(content) {
return content.replace(RE_USE_STRICT_STATEMENT, '$1');
}
}
}
},
uglify: {
dist: {
options: {
report: 'min',
preserveComments: 'some',
sourceMap : 'dist/phalanx.map',
sourceMappingURL : 'phalanx.map',
sourceMapPrefix : 1
},
src: ['dist/phalanx.js'],
dest: 'dist/phalanx.min.js'
}
},
jsduck: {
options: {
'builtin-classes': false,
// @see https://github.com/senchalabs/jsduck/blob/master/lib/jsduck/logger.rb
'warnings': ['-no_doc', '-dup_member', '-link_ambiguous', '-type_name'],
'external': ['XMLHttpRequest']
},
dist: {
src: ['dist/phalanx.debug.js'],
dest: 'docs'
}
},
plato: {
options: {
jshint : grunt.file.readJSON('.jshintrc')
},
dist: {
src: ['src/**/*.js'],
dest: 'reports'
}
},
regarde: {
devel: {
files: ['src/**/*.js'],
tasks: ['concat:debug']
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-regarde');
grunt.loadNpmTasks('grunt-jsduck');
grunt.loadNpmTasks('grunt-plato');
// Default task(s).
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['concat', 'uglify']);
grunt.registerTask('release', ['concat', 'uglify', 'jsduck', 'plato']);
grunt.registerTask('devel', ['regarde']);
};