@@ -77,27 +77,39 @@ module.exports = function(grunt) {
7777 } ,
7878 s3 : {
7979 options : s3 ,
80- prod : {
81- // Files to be uploaded.
80+ minor : {
8281 upload : [
8382 {
8483 src : 'dist/cdn/*' ,
85- dest : 'vjs/' + version . full + '/' ,
84+ dest : 'vjs/' + version . majorMinor + '/' ,
8685 rel : 'dist/cdn/' ,
8786 headers : {
88- 'Cache-Control' : 'public, max-age=31536000 '
87+ 'Cache-Control' : 'public, max-age=2628000 '
8988 }
90- } ,
89+ }
90+ ]
91+ } ,
92+ patch : {
93+ upload : [
9194 {
9295 src : 'dist/cdn/*' ,
93- dest : 'vjs/' + version . majorMinor + '/' ,
96+ dest : 'vjs/' + version . full + '/' ,
9497 rel : 'dist/cdn/' ,
9598 headers : {
96- 'Cache-Control' : 'public, max-age=2628000 '
99+ 'Cache-Control' : 'public, max-age=31536000 '
97100 }
98101 }
99102 ]
100103 }
104+ } ,
105+ cssmin : {
106+ minify : {
107+ expand : true ,
108+ cwd : 'build/files/' ,
109+ src : [ 'video-js.css' ] ,
110+ dest : 'build/files/' ,
111+ ext : '.min.css'
112+ }
101113 }
102114 } ) ;
103115
@@ -106,6 +118,7 @@ module.exports = function(grunt) {
106118 grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
107119 grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
108120 grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
121+ grunt . loadNpmTasks ( 'grunt-contrib-cssmin' ) ;
109122 grunt . loadNpmTasks ( 'grunt-s3' ) ;
110123 grunt . loadNpmTasks ( 'contribflow' ) ;
111124
@@ -133,28 +146,35 @@ module.exports = function(grunt) {
133146 sourceFiles [ i ] = sourceFiles [ i ] . replace ( / \\ / g, '/' ) ;
134147 }
135148
136- // grunt.file.write('build/files/sourcelist.txt', sourceList.join(','));
137- // Allow time for people to update their index.html before they remove these
138- // grunt.file.write('build/files/sourcelist.js', 'var sourcelist = ["' + sourceFiles.join('","') + '"]');
139-
140149 // Create a combined sources file. https://github.com/zencoder/video-js/issues/287
141150 var combined = '' ;
142151 sourceFiles . forEach ( function ( result ) {
143152 combined += grunt . file . read ( result ) ;
144153 } ) ;
154+ // Replace CDN version ref in js. Use major/minor version.
155+ combined = combined . replace ( / G E N E R A T E D _ C D N _ V S N / g, version . majorMinor ) ;
145156 grunt . file . write ( 'build/files/combined.video.js' , combined ) ;
146157
158+ // Copy over other files
147159 grunt . file . copy ( 'src/css/video-js.css' , 'build/files/video-js.css' ) ;
148160 grunt . file . copy ( 'src/css/video-js.png' , 'build/files/video-js.png' ) ;
149161 grunt . file . copy ( 'src/swf/video-js.swf' , 'build/files/video-js.swf' ) ;
150- // grunt.file.copy('src/css/font/', 'build/files/font/');
151162
163+ // Inject version number into css file
164+ var css = grunt . file . read ( 'build/files/video-js.css' ) ;
165+ css = css . replace ( / G E N E R A T E D _ A T _ B U I L D / g, version . full ) ;
166+ grunt . file . write ( 'build/files/video-js.css' , css ) ;
167+
168+ // Copy over font files
152169 grunt . file . recurse ( 'src/css/font' , function ( absdir , rootdir , subdir , filename ) {
153170 // Block .DS_Store files
154171 if ( 'filename' . substring ( 0 , 1 ) !== '.' ) {
155172 grunt . file . copy ( absdir , 'build/files/font/' + filename ) ;
156173 }
157174 } ) ;
175+
176+ // Minify CSS
177+ grunt . task . run ( [ 'cssmin' ] ) ;
158178 } ) ;
159179
160180 grunt . registerMultiTask ( 'minify' , 'Minify JS files using Closure Compiler.' , function ( ) {
@@ -175,24 +195,26 @@ module.exports = function(grunt) {
175195 filePatterns = filePatterns . concat ( this . data . src ) ;
176196 }
177197
198+ // Build closure compiler shell command
178199 var command = 'java -jar build/compiler/compiler.jar'
179200 + ' --compilation_level ADVANCED_OPTIMIZATIONS'
180201 // + ' --formatting=pretty_print'
181202 + ' --js_output_file=' + dest
182203 + ' --create_source_map ' + dest + '.map --source_map_format=V3'
183204 + ' --jscomp_warning=checkTypes --warning_level=VERBOSE'
184- + ' --output_wrapper "/*! ' + pkg . copyright + ' */\n (function() {%output%})();//@ sourceMappingURL=video.js.map"' ;
205+ + ' --output_wrapper "/*! Video.js v' + version . full + ' ' + pkg . copyright + ' */\n (function() {%output%})();//@ sourceMappingURL=video.js.map"' ;
185206
207+ // Add each js file
186208 grunt . file . expand ( filePatterns ) . forEach ( function ( file ) {
187209 command += ' --js=' + file ;
188210 } ) ;
189211
212+ // Add externs
190213 externs . forEach ( function ( extern ) {
191214 command += ' --externs=' + extern ;
192215 } ) ;
193216
194- // grunt.log.writeln(command)
195-
217+ // Run command
196218 exec ( command , { maxBuffer : 500 * 1024 } , function ( err , stdout , stderr ) {
197219
198220 if ( err ) {
@@ -211,14 +233,18 @@ module.exports = function(grunt) {
211233 grunt . registerTask ( 'dist' , 'Creating distribution' , function ( ) {
212234 var exec = require ( 'child_process' ) . exec ;
213235 var done = this . async ( ) ;
236+ var css , jsmin , jsdev ;
214237
238+ // Manually copy each source file
215239 grunt . file . copy ( 'build/files/minified.video.js' , 'dist/video-js/video.js' ) ;
216240 grunt . file . copy ( 'build/files/combined.video.js' , 'dist/video-js/video.dev.js' ) ;
217241 grunt . file . copy ( 'build/files/video-js.css' , 'dist/video-js/video-js.css' ) ;
242+ grunt . file . copy ( 'build/files/video-js.min.css' , 'dist/video-js/video-js.min.css' ) ;
218243 grunt . file . copy ( 'build/files/video-js.swf' , 'dist/video-js/video-js.swf' ) ;
219244 grunt . file . copy ( 'build/demo-files/demo.html' , 'dist/video-js/demo.html' ) ;
220245 grunt . file . copy ( 'build/demo-files/demo.captions.vtt' , 'dist/video-js/demo.captions.vtt' ) ;
221246
247+ // Copy over font files
222248 grunt . file . recurse ( 'build/files/font' , function ( absdir , rootdir , subdir , filename ) {
223249 // Block .DS_Store files
224250 if ( 'filename' . substring ( 0 , 1 ) !== '.' ) {
@@ -227,18 +253,17 @@ module.exports = function(grunt) {
227253 } ) ;
228254
229255 // CDN version uses already hosted font files
230- // Minified version only
231- // doesn't need demo files
256+ // Minified version only, doesn't need demo files
232257 grunt . file . copy ( 'build/files/minified.video.js' , 'dist/cdn/video.js' ) ;
233- grunt . file . copy ( 'build/files/video-js.css' , 'dist/cdn/video-js.css' ) ;
258+ grunt . file . copy ( 'build/files/video-js.min. css' , 'dist/cdn/video-js.css' ) ;
234259 grunt . file . copy ( 'build/files/video-js.swf' , 'dist/cdn/video-js.swf' ) ;
235260
236-
237-
238- var css = grunt . file . read ( 'dist/cdn/video-js.css' ) ;
261+ // Replace font urls with CDN versions
262+ css = grunt . file . read ( 'dist/cdn/video-js.css' ) ;
239263 css = css . replace ( / f o n t \/ / g, '../f/1/' ) ;
240264 grunt . file . write ( 'dist/cdn/video-js.css' , css ) ;
241265
266+ // Zip up into video-js-VERSION.zip
242267 exec ( 'cd dist && zip -r video-js-' + version . full + '.zip video-js && cd ..' , { maxBuffer : 500 * 1024 } , function ( err , stdout , stderr ) {
243268
244269 if ( err ) {
0 commit comments