-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
63 lines (57 loc) · 1.58 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
module.exports = function (grunt) {
'use strict';
/* Third-party packages */
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
stripBanners: true,
separator: '\n',
process: function (src, filepath) {
switch (filepath) {
case 'src/intro.js':
return src.replace(/@([A-Z]+)/g, function (match, $1) {
var param = $1.toLowerCase();
switch (param) {
case 'today':
return grunt.template.today("yyyy-mm-dd");
case 'year':
return grunt.template.today("yyyy");
case 'author':
return grunt.config.data.pkg.author.name;
default:
return grunt.config.data.pkg[param] || '';
}
});
case 'src/outro.js':
return src;
default:
return src.replace(/(^|\n)/g, '$1\t');
}
}
},
dist: {
src: ['src/intro.js', 'src/input.js', 'src/code.js', 'src/matrix.js', 'src/encoder.js', 'src/main.js', 'src/outro.js'],
dest: '<%= pkg.distribution %>/<%= pkg.name.toLowerCase() %>-<%= pkg.version %>.js'
}
},
uglify: {
options: {
preserveComments: 'some',
screwIE8: false,
sourceMap: true
},
dist: {
options: {
maxLineLen: 10
},
files: {
'<%= pkg.distribution %>/<%= pkg.name.toLowerCase() %>-<%= pkg.version %>-min.js': '<%= pkg.distribution %>/<%= pkg.name.toLowerCase() %>-<%= pkg.version %>.js'
}
}
}
});
grunt.registerTask('default', ['concat:dist', 'uglify:dist']);
};