@@ -6,6 +6,7 @@ var requirejs = require( 'requirejs' ),
66
77module . exports = function ( grunt ) {
88 var config = grunt . config . get ( 'global' ) ,
9+ cssmin = { } ,
910 regularFile = path . join ( config . dirs . output , config . names . root ) ,
1011 structureFile = path . join ( config . dirs . output , config . names . structure ) ,
1112 themeFile = path . join ( config . dirs . output , config . names . theme ) ,
@@ -29,67 +30,50 @@ module.exports = function( grunt ) {
2930 }
3031 } ) ;
3132
32- grunt . registerTask ( 'css_without_deps' , 'compile and minify the css' , function ( ) {
33- var done = this . async ( ) ,
34- theme = grunt . config . get ( 'css' ) . theme ,
35- require = grunt . config . get ( 'css' ) . require ,
36- global_config = grunt . config . get ( 'global' ) ;
37-
38- // pull the includes together using require js
39- requirejs . optimize ( require . all ) ;
33+ grunt . config . set ( 'concat' , {
34+ structure : {
35+ src : [ '<banner:global.ver.header>' , structureFile + '.compiled.css' ] ,
36+ dest : structureFile + '.css'
37+ } ,
38+
39+ regular : {
40+ src : [ '<banner:global.ver.header>' , regularFile + '.compiled.css' ] ,
41+ dest : regularFile + '.css'
42+ } ,
43+
44+ theme : {
45+ src : [
46+ '<banner:global.ver.header>' ,
47+ 'css/themes/default/jquery.mobile.theme.css'
48+ ] ,
49+ dest : themeFile + '.css'
50+ }
51+ } ) ;
4052
41- // dump the versioned header into the normal css file
42- grunt . file . write ( regularFile + '.css' , global_config . ver . header ) ;
53+ // setup css min configuration
54+ cssmin [ regularFile + '.min.css' ] = [ "<banner:global.ver.min>" , regularFile + '.css' ] ;
55+ cssmin [ structureFile + '.min.css' ] = [ "<banner:global.ver.min>" , structureFile + '.css' ] ;
56+ cssmin [ themeFile + '.min.css' ] = [ "<banner:global.ver.min>" , themeFile + '.css' ] ;
57+ grunt . config . set ( 'cssmin' , cssmin ) ;
4358
44- // add the compiled css to the normal css file
45- helpers . appendFrom ( regularFile + '. css', require . all . out ) ;
59+ grunt . registerTask ( 'css_compile' , 'use require js to sort out deps' , function ( ) {
60+ var require = grunt . config . get ( ' css' ) . require ;
4661
47- helpers . minify ( {
48- output : regularFile + '.min.css' ,
49- input : regularFile + '.css' ,
50- header : global_config . ver . min ,
51- minCallback : function ( unminified ) {
52- return sqwish . minify ( unminified , false ) ;
53- }
54- } ) ;
62+ // pull the includes together using require js
63+ requirejs . optimize ( require . all ) ;
5564
5665 // pull the includes together using require js
5766 requirejs . optimize ( require . structure ) ;
5867
59- // dump the versioned header into the structure css file
60- grunt . file . write ( structureFile + '.css' , global_config . ver . header ) ;
61-
62- // add the compiled structure css to the normal css file
63- helpers . appendFrom ( structureFile + '.css' , require . structure . out ) ;
64-
65- // add the min header into the minified file
66- grunt . file . write ( structureFile + '.min.css' , global_config . ver . min ) ;
67-
68- // minify the structure css
69- helpers . minify ( {
70- output : structureFile + '.min.css' ,
71- input : structureFile + '.css' ,
72- header : global_config . ver . min ,
73- minCallback : function ( unminified ) {
74- return sqwish . minify ( unminified , false ) ;
75- }
76- } ) ;
77-
78- // dump the versioned header into the theme css file
79- grunt . file . write ( themeFile + '.css' , global_config . ver . header ) ;
80-
81- // dump the theme css into the theme css file
82- helpers . appendFrom ( themeFile + '.css' , 'css/themes/default/jquery.mobile.theme.css' ) ;
68+ // simple theme file compile
69+ grunt . file . write ( themeFile + '.css' , 'css/themes/default/jquery.mobile.theme.css' ) ;
70+ } ) ;
8371
84- // minify the theme css
85- helpers . minify ( {
86- output : themeFile + '.min.css' ,
87- input : themeFile + '.css' ,
88- header : global_config . ver . min ,
89- minCallback : function ( unminified ) {
90- return sqwish . minify ( unminified , false ) ;
91- }
92- } ) ;
72+ grunt . registerTask ( 'css_cleanup' , 'compile and minify the css' , function ( ) {
73+ var done = this . async ( ) ,
74+ theme = grunt . config . get ( 'css' ) . theme ,
75+ require = grunt . config . get ( 'css' ) . require ,
76+ global_config = grunt . config . get ( 'global' ) ;
9377
9478 // remove the requirejs compile output
9579 fs . unlink ( require . all . out ) ;
@@ -111,5 +95,5 @@ module.exports = function( grunt ) {
11195 } ) ;
11296 } ) ;
11397
114- grunt . registerTask ( 'css' , 'async_config custom_init css_without_deps ' ) ;
98+ grunt . registerTask ( 'css' , 'custom_init async_config css_compile concat:regular concat:structure concat:theme cssmin css_cleanup ' ) ;
11599} ;
0 commit comments