1 var path = require( 'path' ), fs = require( 'fs' );
3 module.exports = function( grunt ) {
4 var dirs, names, min = {}, cssmin = {},
5 theme, rootFile, structureFile, themeFile,
13 verOfficial = grunt.file.read( 'version.txt' ).replace(/\n/, '');
15 suffix = process.env.IS_DEPLOY_TARGET === "true" ? "-" + verOfficial : "";
18 base: 'jquery.mobile' + suffix,
19 // this will change for the deploy target to include version information
20 root: 'jquery.mobile' + suffix,
21 structure: 'jquery.mobile.structure' + suffix,
22 theme: 'jquery.mobile.theme' + suffix
25 function outputPath( name ){
26 return path.join( dirs.output, name );
29 rootFile = outputPath( names.root );
30 structureFile = outputPath( names.structure );
31 themeFile = outputPath( names.theme );
33 // TODO again, I'd like to use grunt params but I'm not sure
34 // how to get that working with a custom task with deps
35 theme = process.env.THEME || 'default';
37 // Project configuration.
44 // (function(){})() seems acceptable
61 // TODO would be nice to confine these to test files
77 // TODO add test files here once we can specify different configs for
80 files: [ 'js/**/*.mobile.*.js', 'js/*/*.js' ]
83 // NOTE these configuration settings are used _after_ compilation has taken place
84 // using requirejs. Thus the .compiled extensions. The exception being the theme concat
87 src: [ '<banner:global.ver.header>', rootFile + '.compiled.js' ],
88 dest: rootFile + '.js'
92 src: [ '<banner:global.ver.header>', structureFile + '.compiled.css' ],
93 dest: structureFile + '.css'
97 src: [ '<banner:global.ver.header>', rootFile + '.compiled.css' ],
98 dest: rootFile + '.css'
103 '<banner:global.ver.header>',
104 'css/themes/' + theme + '/jquery.mobile.theme.css'
106 dest: themeFile + '.css'
110 // NOTE the keys are filenames which, being stored as variables requires that we use
111 // key based assignment. See below.
115 // JS config, mostly the requirejs configuration
119 name: 'jquery.mobile',
124 'text!../version.txt'
126 out: rootFile + '.compiled.js',
127 pragmasOnSave: { jqmBuildExclude: true },
128 wrap: { startFile: 'build/wrap.start', endFile: 'build/wrap.end' },
129 findNestedDependencies: true,
130 skipModuleInsertion: true,
135 // CSS config, mostly the requirejs configuration
137 theme: process.env.THEME || 'default',
139 themeFile: themeFile,
143 cssIn: 'css/themes/default/jquery.mobile.css',
144 optimizeCss: 'standard.keepComments.keepLines',
146 out: rootFile + '.compiled.css'
150 cssIn: 'css/structure/jquery.mobile.structure.css',
151 out: structureFile + '.compiled.css'
162 license: 'LICENSE-INFO.txt'
165 // other version information is added via the asyncConfig helper that
166 // depends on git commands (eg ver.min, ver.header)
168 official: verOfficial,
169 min: '/*! jQuery Mobile v<%= build_sha %> jquerymobile.com | jquery.org/license !*/',
170 gitLongSha: 'git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd"',
171 gitShortSha: 'git log -1 --format=format:"%H"'
179 min[ rootFile + '.min.js' ] = [ "<banner:global.ver.min>", rootFile + '.js' ];
180 grunt.config.set( 'min', min );
182 // CSSMIN configuration
183 cssmin[ rootFile + '.min.css' ] = [ "<banner:global.ver.min>", rootFile + '.css' ];
184 cssmin[ structureFile + '.min.css' ] = [ "<banner:global.ver.min>", structureFile + '.css' ];
185 cssmin[ themeFile + '.min.css' ] = [ "<banner:global.ver.min>", themeFile + '.css' ];
186 grunt.config.set( 'cssmin', cssmin );
188 // set the default task.
189 grunt.registerTask('default', 'lint');
191 // csslint and cssmin tasks
192 grunt.loadNpmTasks( "grunt-css" );
195 grunt.loadNpmTasks( "grunt-git-authors" );
197 grunt.loadNpmTasks( "grunt-junit" );
199 // A convenient task alias.
200 grunt.registerTask('test', 'config:test:pages config:test junit');
202 // Ease of use aliases for users who want the zip and docs
203 grunt.registerTask('docs', 'js css legacy_tasks:docs');
204 grunt.registerTask('zip', 'js css legacy_tasks:zip');
206 // load the project's default tasks
207 grunt.loadTasks( 'build/tasks');