-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
62 lines (53 loc) · 1.62 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
// @TODO Write a container generator
var fs = require('fs');
var jsBeautify = require('js-beautify').js_beautify;
var outputFilename = 'html5-media-listener';
module.exports = function(grunt) {
var footer = ['/*',
' * v<%= pkg.version %>',
' * Created by the Google Analytics consultants at http://www.lunametrics.com/',
' * Written by @notdanwilkerson',
' * Documentation: https://github.com/lunametrics/html5-media-listener/',
' * Licensed under the MIT License',
' */'
].join('\r\n');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
ignore_warning: {
options: {
'-W030': true,
'-W058': true
},
src: ['./src/*.js']
}
},
uglify: {
options: {
footer: '\r\n' + footer
},
build: {
src: './src/index.js',
dest: './' + outputFilename + '.min.js'
}
},
appendFooter: {
options: {
build: {
src: './src/index.js',
dest: './' + outputFilename + '.js'
},
footer: footer
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('appendFooter', ['append credits to footer'], function() {
var options = this.options();
var data = fs.readFileSync(options.build.src, 'utf-8');
fs.writeFileSync(options.build.dest, data + options.footer);
console.log('appended footer to unminifed script');
});
grunt.registerTask('default', ['jshint', 'appendFooter', 'uglify']);
};