forked from szimek/signature_pad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
91 lines (81 loc) · 3.12 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
/*jslint node: true */
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'src/signature_pad.js'
]
},
banner: {
dev: {
options: {
banner: "/*!\n" +
" * Signature Pad v<%= pkg.version %>\n" +
" * <%= pkg.homepage %>\n" +
" *\n" +
" * Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" +
" * Released under the MIT license\n" +
" *\n" +
" * The main idea and some parts of the code (e.g. drawing variable width Bézier curve) are taken from:\n" +
" * http://corner.squareup.com/2012/07/smoother-signatures.html\n" +
" *\n" +
" * Implementation of interpolation using cubic Bézier curves is taken from:\n" +
" * http://benknowscode.wordpress.com/2012/09/14/path-interpolation-using-cubic-bezier-and-control-point-estimation-in-javascript\n" +
" *\n" +
" * Algorithm for approximated length of a Bézier curve is taken from:\n" +
" * http://www.lemoda.net/maths/bezier-length/index.html\n" +
" *\n" +
" */\n"
},
files: {
'signature_pad.js': ['src/signature_pad.js']
}
},
dist: {
options: {
banner: "/*!\n" +
" * Signature Pad v<%= pkg.version %> | <%= pkg.homepage %>\n" +
" * (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %> | Released under the MIT license\n" +
" */\n"
},
files: {
'signature_pad.min.js': ['src/signature_pad.js']
}
}
},
uglify: {
dist: {
options: {
preserveComments: 'some'
},
files: {
'signature_pad.min.js': ['signature_pad.min.js']
}
}
}
});
grunt.registerMultiTask('banner', 'Add banner to files.', function () {
var options = this.options({
banner: ''
});
var banner = grunt.template.process(options.banner);
this.files.forEach(function (f) {
var output = grunt.file.read(f.src);
output = banner + output;
grunt.file.write(f.dest, output);
});
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', [
'jshint',
'banner',
'uglify'
]);
};