11module . exports = function ( grunt ) {
2- // Project configuration.
2+
33 grunt . initConfig ( {
4+
45 properties : grunt . file . readJSON ( 'properties.json' ) ,
6+
57 pkg : grunt . file . readJSON ( 'package.json' ) ,
6- clean : [ '<%= properties.webappBuildDir %>' ] ,
7- sync : [
8- // copy tests
9- { expand : true , cwd : '<%= properties.webappTestDir %>' , src : '**' , dest : '<%= properties.webappBuildDir %>' } ,
10-
11- // copy tests resources
12- { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1/ttml/**' , dest : '<%= properties.webappBuildDir %>' } ,
13- { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1/tests.json' , dest : '<%= properties.webappBuildDir %>' } ,
14- { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1_1/ttml/**' , dest : '<%= properties.webappBuildDir %>' } ,
15- { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1_1/tests.json' , dest : '<%= properties.webappBuildDir %>' } ,
16- { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'unit-tests/**' , dest : '<%= properties.webappBuildDir %>' }
17- ] ,
8+
9+ clean : [ '<%= properties.webappBuildDir %>' , '<%= properties.umdBuildDir %>' ] ,
10+
11+ sync : {
12+ all : {
13+ files :
14+ [
15+ // copy tests
16+ { expand : true , cwd : '<%= properties.webappTestDir %>' , src : '**' , dest : '<%= properties.webappBuildDir %>' } ,
17+
18+ // copy tests resources
19+ { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1/ttml/**' , dest : '<%= properties.webappBuildDir %>' } ,
20+ { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1/tests.json' , dest : '<%= properties.webappBuildDir %>' } ,
21+ { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1_1/ttml/**' , dest : '<%= properties.webappBuildDir %>' } ,
22+ { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'imsc-tests/imsc1_1/tests.json' , dest : '<%= properties.webappBuildDir %>' } ,
23+ { expand : true , cwd : '<%= properties.unitTestsResourcesDir %>' , src : 'unit-tests/**' , dest : '<%= properties.webappBuildDir %>' }
24+ ]
25+ } ,
26+
27+ release : {
28+ src : '<%= properties.umdBuildDir %>/<%= properties.umdMinName %>' ,
29+ dest : '<%= properties.webappBuildDir %>/libs/imsc.js'
30+ } ,
31+
32+ debug : {
33+ src : '<%= properties.umdBuildDir %>/<%= properties.umdDebugName %>' ,
34+ dest : '<%= properties.webappBuildDir %>/libs/imsc.js'
35+ }
36+ } ,
37+
1838 npmcopy : {
1939 default : {
2040 files : {
@@ -28,40 +48,67 @@ module.exports = function (grunt) {
2848 }
2949 }
3050 } ,
31- browserify : {
32- default : {
33- src : "./src/main/js/main.js" ,
34- dest : "<%= properties.webappBuildDir %>/libs/imsc.js" ,
51+
52+ browserify : [
53+ {
54+ src : "<%= pkg.main %>" ,
55+ dest : "<%= properties.umdBuildDir %>/<%= properties.umdDebugName %>" ,
3556 options : {
3657 exclude : [ "sax" ] ,
3758 browserifyOptions : {
3859 standalone : 'imsc'
3960 }
4061 }
62+ } ,
63+ {
64+ src : "<%= pkg.main %>" ,
65+ dest : "<%= properties.umdBuildDir %>/<%= properties.umdAllDebugName %>" ,
66+ options : {
67+ browserifyOptions : {
68+ standalone : 'imsc'
69+ }
70+ }
4171 }
42- } ,
72+ ] ,
73+
4374 jshint : {
44- default : {
75+ ' default' : {
4576 src : "src/main/js" ,
4677 options : {
4778 "-W032" : true
4879 }
4980 }
81+ } ,
82+
83+ exec : {
84+ minify :
85+ {
86+ cmd : [
87+ "npx google-closure-compiler --js=<%= properties.umdBuildDir %>/<%= properties.umdAllDebugName %> --js_output_file=<%= properties.umdBuildDir %>/<%= properties.umdAllMinName %>" ,
88+ "npx google-closure-compiler --js=<%= properties.umdBuildDir %>/<%= properties.umdDebugName %> --js_output_file=<%= properties.umdBuildDir %>/<%= properties.umdMinName %>"
89+ ] . join ( "&&" )
90+ }
5091 }
51- } ) ;
92+ }
93+
94+ ) ;
5295
5396 grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
5497
5598 grunt . loadNpmTasks ( 'grunt-npmcopy' ) ;
5699
57100 grunt . loadNpmTasks ( 'grunt-browserify' ) ;
58-
101+
59102 grunt . loadNpmTasks ( 'grunt-contrib-jshint' ) ;
60-
103+
61104 grunt . loadNpmTasks ( 'grunt-sync' ) ;
62105
63- grunt . registerTask ( 'build' , [ 'jshint' , 'sync' , 'npmcopy' , 'browserify' ] ) ;
64-
106+ grunt . loadNpmTasks ( 'grunt-exec' ) ;
107+
108+ grunt . registerTask ( 'build:release' , [ 'jshint' , 'browserify' , 'exec:minify' , 'sync:all' , 'sync:release' , 'npmcopy' ] ) ;
109+
110+ grunt . registerTask ( 'build:debug' , [ 'jshint' , 'browserify' , 'exec:minify' , 'sync:all' , 'sync:debug' , 'npmcopy' ] ) ;
111+
65112 grunt . registerTask ( 'clean' , [ 'clean' ] ) ;
66113
67114} ;
0 commit comments