-
Notifications
You must be signed in to change notification settings - Fork 76
/
Gruntfile.js
59 lines (50 loc) · 1.41 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
/* eslint-env node */
module.exports = function(grunt) {
'use strict';
require('time-grunt')(grunt);
require('jit-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
eslint: {
src: {
src: [
'Gruntfile.js',
'src/bigscreen.js'
]
}
},
uglify: {
unminified: {
options: {
banner: '/*! <%= pkg.name %>\n * v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n * <%= pkg.homepage %>\n * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>; <%= pkg.license %> License\n */\n',
mangle: false,
compress: false,
preserveComments: 'some',
beautify: true
},
files: {
'bigscreen.js': ['src/bigscreen.js']
}
},
minified: {
options: {
banner: '// <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> - <%= pkg.license %> License',
sourceMap: true
},
files: {
'bigscreen.min.js': ['src/bigscreen.js']
}
}
}
});
grunt.registerTask('remove_map_comment', function() {
var fs = require('fs');
var files = Object.keys(grunt.config('uglify.minified.files'));
files.forEach(function(file) {
var text = fs.readFileSync(file, 'utf8').replace(/\/\/# sourceMappingURL=\S+/, '');
fs.writeFileSync(file, text);
});
});
grunt.registerTask('default', ['eslint']);
grunt.registerTask('build', ['eslint', 'uglify', 'remove_map_comment']);
};