-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathGruntfile.js
103 lines (93 loc) · 2.04 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
99
100
101
102
103
/*global module:false */
module.exports = function(grunt) {
'use strict';
var pkg = grunt.file.readJSON( 'package.json' );
// Project configuration.
grunt.initConfig({
pkg: pkg,
clean: {
dist: {
src: ['dist/*']
}
},
copy: {
dist: {
files : [{
expand: true,
dot: true,
flatten: true,
src: [ 'css/anythingzoomer.css', 'js/jquery.anythingzoomer.js' ],
dest: 'dist/'
}]
}
},
jshint: {
core: {
options: {
"jquery": true,
"browser": true
},
src: [ 'js/jquery.*.js' ]
}
},
cssmin: {
target: {
files: [{
expand: true,
flatten: true,
src: ['css/*.css'],
dest: 'dist/',
ext: '.min.css'
}]
}
},
uglify: {
options: {
preserveComments: function( node, comment ) {
return /^!/.test( comment.value );
},
report: 'gzip'
},
dist: {
files: [{
expand: true,
cwd: '',
src: [ 'js/*.js' ],
dest: 'dist/',
ext: '.min.js',
extDot: 'last',
flatten: true
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task.
grunt.registerTask('default', [
'clean',
'jshint',
'copy',
'cssmin',
'uglify',
'updateManifest'
]);
// update files version in other json files to match the package.json version
grunt.registerTask( 'updateManifest', function() {
var i, project,
projectFile = [ 'anythingzoomer.jquery.json' ],
len = projectFile.length;
for ( i = 0; i < len; i++ ) {
if ( !grunt.file.exists( projectFile[ i ] ) ) {
grunt.log.error( 'file ' + projectFile[ i ] + ' not found' );
return true; // return false to abort the execution
}
project = grunt.file.readJSON( projectFile[ i ] ); // get file as json object
project.version = pkg.version;
grunt.file.write( projectFile[i], JSON.stringify( project, null, 2 ) ); // serialize it back to file
}
});
};