forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
117 lines (108 loc) · 2.59 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*global module:true*/
(function () {
"use strict";
var pkg;
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: pkg = grunt.file.readJSON("package.json"),
banner: "/*! <%= pkg.name %> - v<%= pkg.version %> */\n",
// Task configuration.
uglify: {
options: {
banner: "<%= banner %>",
compress: {
dead_code: true
}
},
plugins: {
files: [
{
expand: true,
cwd: 'plugins/',
src: ['**/*.js', '!*.min.js', '!**/*.min.js'],
dest: 'plugins/',
ext: '.min.js',
extDot: 'last'
},
{
expand: true,
cwd: '',
src: ['lazysizes*.js', '!*.min.js'],
dest: '',
ext: '.min.js',
extDot: 'last'
}
]
}
},
jshint: {
all: {
options: {
jshintrc: true
},
src: [ "lazysizes.js", "plugins/**/*.js", "!*.min.js", "!plugins/**/*.min.js" ] //, "Gruntfile.js", "tests/*.js"
}
},
plato: {
all: {
files: {
"plato-report/": ["lazysizes.js", "plugins/**/*.js", "!*.min.js", "!plugins/**/*.min.js"]
}
}
},
qunit: {
all: ['tests/*.html']
},
watch: {
gruntfile: {
files: [ "Gruntfile.js", "lazysizes.js" ],
tasks: [ "default" ]
}
},
bytesize: {
all: {
src: [ "lazysizes.min.js" ]
}
},
uncss: {
dist: {
files: {
'assets/css/tidy.css': ['index.html', 'maxdpr/*.html']
}
}
},
maxFilesize: {
options: {
// Task-specific options go here.
},
minified: {
options: {
maxBytes: (1024 * 6.8)
},
src: ["lazysizes.min.js"]
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-uncss');
grunt.loadNpmTasks('grunt-bytesize');
grunt.loadNpmTasks('grunt-max-filesize');
grunt.loadNpmTasks('grunt-plato');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.registerTask('wrapcore', 'wraps lazysizes into umd and common wrapper.', function() {
var ls = grunt.file.read('src/lazysizes-core.js');
var common = grunt.file.read('src/common.wrapper');
var umd = grunt.file.read('src/umd.wrapper');
grunt.file.write('lazysizes.js', common.replace('{{ls}}', ls));
grunt.file.write('lazysizes-umd.js', umd.replace('{{ls}}', ls));
});
// Default task.
grunt.registerTask("default", [ "wrapcore", "test", "uglify", "bytesize", "maxFilesize" ]);
grunt.registerTask("test", [ "jshint" ]);
};
})();