forked from desandro/imagesloaded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
62 lines (51 loc) · 1.46 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
// -------------------------- grunt -------------------------- //
module.exports = function( grunt ) {
// get banner comment from imagesloaded.js
var banner = ( function() {
var contents = grunt.file.read('imagesloaded.js');
var re = new RegExp('^\\s*(?:\\/\\*[\\s\\S]*?\\*\\/)\\s*');
var matches = contents.match( re );
return matches[0].replace( 'imagesLoaded', 'imagesLoaded PACKAGED' );
})();
grunt.initConfig({
requirejs: {
// create imagesloaded.pkgd.js
pkgd: {
options: {
baseUrl: 'bower_components',
include: [
'../imagesloaded'
],
out: 'imagesloaded.pkgd.js',
optimize: 'none',
wrap: {
start: banner
}
}
}
},
uglify: {
pkgd: {
files: {
'imagesloaded.pkgd.min.js': [ 'imagesloaded.pkgd.js' ]
},
options: {
banner: banner
}
}
},
});
grunt.loadNpmTasks('grunt-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask( 'remove-pkgd-module-name', function() {
var contents = grunt.file.read('imagesloaded.pkgd.js');
contents = contents.replace( "'../imagesloaded',", '' );
grunt.file.write( 'imagesloaded.pkgd.js', contents );
grunt.log.writeln('Removed pkgd module name on imagesloaded.pkgd.js');
});
grunt.registerTask( 'default', [
'requirejs',
'remove-pkgd-module-name',
'uglify'
]);
};