forked from darsain/sly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
98 lines (86 loc) · 2.24 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
/*jshint node:true */
module.exports = function (grunt) {
'use strict';
// Override environment based line endings enforced by Grunt
grunt.util.linefeed = '\n';
// Grunt configuration
grunt.initConfig({
pkg: grunt.file.readJSON('meta.json'),
meta: {
banner: '/*!\n' +
' * <%= pkg.name %> <%= pkg.version %> - <%= grunt.template.today("dS mmm yyyy") %>\n' +
' * <%= pkg.repository.homepage %>\n' +
' *\n' +
' * Licensed under the <%= pkg.licenses[0].type %> license.\n' +
' * <%= pkg.licenses[0].url %>\n' +
' */\n',
bannerLight: '/*! <%= pkg.name %> <%= pkg.version %>' +
' - <%= grunt.template.today("dS mmm yyyy") %> | <%= pkg.repository.homepage %> */'
},
// JSHint the code.
jshint: {
options: {
jshintrc: true
},
all: ['src/*.js']
},
// Clean folders.
clean: {
dist: ['dist/**', '!dist']
},
// Concatenate files.
concat: {
dist: {
options: {
banner: '<%= meta.banner %>'
},
src: 'src/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>.js'
}
},
// Minify UglifyJS.
uglify: {
dist: {
options: {
banner: '<%= meta.bannerLight %>\n'
},
src: 'src/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
// Bump up fields in JSON files.
bumpup: {
options: {
updateProps: {
pkg: 'meta.json',
},
},
files: ['meta.json', '<%= pkg.name %>.jquery.json'],
},
// Commit changes and tag the latest commit with a version from JSON file.
tagrelease: '<%= pkg.version %>'
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-tagrelease');
grunt.loadNpmTasks('grunt-bumpup');
// Build task.
grunt.registerTask('build', function () {
grunt.task.run('clean');
grunt.task.run('concat');
grunt.task.run('uglify');
});
// Release task.
grunt.registerTask('release', function (type) {
type = type ? type : 'patch';
grunt.task.run('jshint');
grunt.task.run('bumpup:' + type);
grunt.task.run('build');
grunt.task.run('tagrelease');
});
// Default task.
grunt.registerTask('default', ['jshint']);
};