File tree Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ node_modules
44components
55explorations
66test /vue.test.js
7- test /vue.test-cov.js
7+ test /vue.test-cov.js
8+ dist /vue.min.js.gz
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module.exports = function( grunt ) {
66
77 grunt . initConfig ( {
88
9- pkg : grunt . file . readJSON ( 'package.json' ) ,
9+ version : grunt . file . readJSON ( 'package.json' ) . version ,
1010
1111 componentbuild : {
1212 build : {
@@ -95,7 +95,9 @@ module.exports = function( grunt ) {
9595
9696 grunt . registerTask ( 'default' , [
9797 'jshint' ,
98- 'test'
98+ 'test' ,
99+ 'uglify' ,
100+ 'size'
99101 ] )
100102
101103}
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ module.exports = function (grunt) {
5353 'test' ,
5454 'version:' + next ,
5555 'uglify' ,
56+ 'size' ,
5657 'git:' + next
5758 ] )
5859 }
Original file line number Diff line number Diff line change 1+ var fs = require ( 'fs' ) ,
2+ zlib = require ( 'zlib' ) ,
3+ min = 'dist/vue.min.js' ,
4+ gz = 'dist/vue.min.js.gz'
5+
6+ module . exports = function ( grunt ) {
7+
8+ grunt . registerTask ( 'size' , function ( ) {
9+
10+ var done = this . async ( )
11+
12+ fs . createReadStream ( min )
13+ . pipe ( zlib . createGzip ( ) )
14+ . pipe ( fs . createWriteStream ( gz ) )
15+ . on ( 'finish' , compareSizes )
16+
17+ function compareSizes ( ) {
18+ var minSize = ( fs . statSync ( min ) . size / 1024 ) . toFixed ( 2 ) ,
19+ gzSize = ( fs . statSync ( gz ) . size / 1024 ) . toFixed ( 2 )
20+ console . log (
21+ '\n\x1b[1m\x1b[34m' +
22+ 'File Sizes:' +
23+ '\x1b[39m\x1b[22m'
24+ )
25+ console . log ( 'Min : ' + minSize + 'kb' )
26+ console . log ( 'Gzip : ' + gzSize + 'kb' )
27+ done ( )
28+ }
29+ } )
30+
31+ }
You can’t perform that action at this time.
0 commit comments