Skip to content

Commit 43f1508

Browse files
Several minor changes to the development process
* Add compare_size for better file size diffs, FYI this is the same used by jQuery; * Updating uglify removes reports by default, let's delegate a better diff for compare_size task instead; * Add grunt watch to develop without having to type grunt everytime (need to add to the contributing docs); * Separate cli task from grunt default, so we can enforce minify and compare_size checks for local development; * Add gzip compression for compare_size so we can compare gzipped content too;
1 parent 047d82f commit 43f1508

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
build
2+
build
3+
.sizecache.json

‎Gruntfile.js‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,33 @@ module.exports = function (grunt) {
2323
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> */\n'
2424
},
2525
build: {
26-
src: 'jquery.cookie.js',
27-
dest: 'build/jquery.cookie-<%= pkg.version %>.min.js'
26+
files: {
27+
'build/jquery.cookie-<%= pkg.version %>.min.js': 'jquery.cookie.js'
28+
}
29+
}
30+
},
31+
watch: {
32+
files: ['jquery.cookie.js', 'test/tests.js'],
33+
tasks: 'default'
34+
},
35+
compare_size: {
36+
files: [ 'build/jquery.cookie-<%= pkg.version %>.min.js', 'jquery.cookie.js' ],
37+
options: {
38+
compress: {
39+
gz: function( fileContents ) {
40+
return require( 'gzip-js' ).zip( fileContents, {} ).length;
41+
}
42+
}
2843
}
2944
}
3045
});
3146

3247
grunt.loadNpmTasks('grunt-contrib-jshint');
3348
grunt.loadNpmTasks('grunt-contrib-uglify');
3449
grunt.loadNpmTasks('grunt-contrib-qunit');
50+
grunt.loadNpmTasks('grunt-contrib-watch');
51+
grunt.loadNpmTasks('grunt-compare-size');
3552

36-
grunt.registerTask('default', ['jshint', 'qunit']);
37-
grunt.registerTask('ci', ['default']);
53+
grunt.registerTask('default', ['jshint', 'qunit', 'uglify', 'compare_size']);
54+
grunt.registerTask('ci', ['jshint', 'qunit']);
3855
};

‎package.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
"readmeFilename": "README.md",
2020
"devDependencies": {
2121
"grunt": "~0.4.0",
22-
"grunt-contrib-jshint": "~0.1.0",
23-
"grunt-contrib-uglify": "~0.1.0",
24-
"grunt-contrib-qunit": "~0.1.0"
22+
"grunt-contrib-jshint": "~0.4.0",
23+
"grunt-contrib-uglify": "~0.2.0",
24+
"grunt-contrib-qunit": "~0.2.0",
25+
"grunt-contrib-watch": "~0.3.0",
26+
"grunt-compare-size": "~0.4.0",
27+
"gzip-js": "~0.3.0"
2528
}
2629
}

0 commit comments

Comments
 (0)