forked from ntkog/filesize.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
88 lines (86 loc) · 1.94 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
module.exports = function(grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
concat: {
options : {
banner : "/**\n" +
" * <%= pkg.name %>\n" +
" *\n" +
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n" +
" * @license <%= pkg.license %>\n" +
" * @version <%= pkg.version %>\n" +
" */\n"
},
dist: {
src : [
"<banner>",
"src/intro.js",
"src/filesize.js",
"src/outro.js"
],
dest : "lib/filesize.es6.js"
}
},
"babel": {
options: {
sourceMap: false,
presets: ["babel-preset-es2015"]
},
dist: {
files: {
"lib/<%= pkg.name %>.js": "lib/<%= pkg.name %>.es6.js"
}
}
},
eslint: {
target: ["lib/<%= pkg.name %>.es6.js"]
},
nodeunit : {
all : ["test/*.js"]
},
sed : {
"version" : {
pattern : "{{VERSION}}",
replacement : "<%= pkg.version %>",
path : ["<%= concat.dist.dest %>"]
}
},
uglify: {
options: {
banner : "/*\n" +
" <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" +
" @version <%= pkg.version %>\n" +
" */",
sourceMap: true,
sourceMapIncludeSources: true
},
target: {
files: {
"lib/filesize.min.js" : ["lib/filesize.js"]
}
}
},
watch : {
js : {
files : "<%= concat.dist.src %>",
tasks : "build"
},
pkg: {
files : "package.json",
tasks : "build"
}
}
});
// tasks
grunt.loadNpmTasks("grunt-sed");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-eslint");
// aliases
grunt.registerTask("test", ["eslint", "nodeunit"]);
grunt.registerTask("build", ["concat", "sed", "babel"]);
grunt.registerTask("default", ["build", "test", "uglify"]);
};