diff options
author | Russell Branca <chewbranca@gmail.com> | 2013-03-19 15:03:47 -0700 |
---|---|---|
committer | Russell Branca <chewbranca@gmail.com> | 2013-03-19 15:03:47 -0700 |
commit | f0b351022d60ae2d5753fa6c38ffb604c2701c46 (patch) | |
tree | 8d561304afd7cdf7b21ddfa2610315d198b6ee4b | |
parent | e5aeb140f24701c4b8181ea530328a789675f3e6 (diff) | |
download | couchdb-f0b351022d60ae2d5753fa6c38ffb604c2701c46.tar.gz |
Fix all the Grunt things
* Fix CSS minimization COUCHDB-1701
* Fix Grunt upgrade to 0.4 COUCHDB-1713
* Fix couchdb task
* Substantial task deduplication
* Refactor various tasks
* Remove old cruft
-rw-r--r-- | src/fauxton/Gruntfile.js | 102 | ||||
-rw-r--r-- | src/fauxton/couchapp.js | 2 | ||||
-rw-r--r-- | src/fauxton/package.json | 1 |
3 files changed, 60 insertions, 45 deletions
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js index 199eb2df6..9de08d596 100644 --- a/src/fauxton/Gruntfile.js +++ b/src/fauxton/Gruntfile.js @@ -146,35 +146,31 @@ module.exports = function(grunt) { dest: "dist/debug/js/require.js" }, - debug: { + index_css: { src: ["dist/debug/css/*.css", 'assets/css/*.css'], dest: 'dist/debug/css/index.css' } }, - // This task uses the MinCSS Node.js project to take all your CSS files in - // order and concatenate them into a single CSS file named index.css. It - // also minifies all the CSS as well. This is named index.css, because we - // only want to load one stylesheet in index.html. - mincss: { - "dist/release/css/index.css": [ - "dist/debug/css/index.css", 'assets/css/*.css', - "app/addons/**/assets/css/*.css" - ] - }, - - // Takes the built require.js file and minifies it for filesize benefits. - min: { - "dist/release/js/require.min.js": [ - "dist/debug/js/require.js" - ] + cssmin: { + compress: { + files: { + "dist/release/css/index.css": [ + "dist/debug/css/index.css", 'assets/css/*.css', + "app/addons/**/assets/css/*.css" + ] + }, + options: { + report: 'min' + } + } }, uglify: { release: { files: { - "dist/release/js/require.min.js": [ + "dist/release/js/require.js": [ "dist/debug/js/require.js" ] } @@ -236,33 +232,28 @@ module.exports = function(grunt) { files: [ // this gets built in the template task {src: "dist/release/index.html", dest: "../../share/www/fauxton/index.html"}, - {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'assets/js/', expand: true}, + {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'dist/release/js/', expand: true}, {src: ["**"], dest: "../../share/www/fauxton/img/", cwd:'dist/release/img/', expand: true}, - {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/release/css/", expand: true}, - // Must be possible to improve this... - {src: ["**"], dest: "../../share/www/fauxton/app/", cwd:"dist/release/", expand: true} + {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/release/css/", expand: true} ] }, couchdebug: { files: [ // this gets built in the template task {src: "dist/debug/index.html", dest: "../../share/www/fauxton/index.html"}, - {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'assets/js/', expand: true}, + {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'dist/debug/js/', expand: true}, {src: ["**"], dest: "../../share/www/fauxton/img/", cwd:'dist/debug/img/', expand: true}, - {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/debug/css/", expand: true}, - // Must be possible to improve this... - {src: ["**"], dest: "../../share/www/fauxton/app/", cwd:"dist/debug/", expand: true} + {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/debug/css/", expand: true} ] }, dist:{ files:[ - {src: ["**"], dest: "dist/release/js/", cwd:'assets/js/', expand: true}, - {src: assets.img, dest: "dist/debug/img/", flatten: true, expand: true} + {src: "dist/debug/index.html", dest: "dist/release/index.html"}, + {src: assets.img, dest: "dist/release/img/", flatten: true, expand: true} ] }, debug:{ files:[ - {src: ["**"], dest: "dist/debug/js/", cwd:'assets/js/', expand: true}, {src: assets.img, dest: "dist/debug/img/", flatten: true, expand: true} ] } @@ -286,6 +277,9 @@ module.exports = function(grunt) { }); + /* + * Load Grunt plugins + */ // Load fauxton specific tasks grunt.loadTasks('tasks'); // Load the couchapp task @@ -298,28 +292,48 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-requirejs'); // Load UglifyJS task grunt.loadNpmTasks('grunt-contrib-uglify'); + // Load CSSMin task + grunt.loadNpmTasks('grunt-contrib-cssmin'); + + /* + * Default task + */ + // defult task - install minified app to local CouchDB + grunt.registerTask('default', 'couchdb'); + + /* + * Transformation tasks + */ // clean out previous build artefacts, lint and unit test - grunt.registerTask('test',['clean','jshint']); //qunit + grunt.registerTask('test', ['clean', 'jshint']); //qunit // Fetch dependencies (from git or local dir), lint them and make load_addons grunt.registerTask('dependencies', ['get_deps', 'jshint', 'gen_load_addons:default']); // build templates, js and css - grunt.registerTask('build', ['jst', 'requirejs', 'concat:requirejs','less']); + grunt.registerTask('build', ['jst', 'requirejs', 'concat:requirejs', 'less', 'concat:index_css', 'template']); // minify code and css, ready for release. - grunt.registerTask('minify', ['min','mincss']); - // deafult task - push to CouchDB - grunt.registerTask('default', ['test','dependencies','build','release','install']); - grunt.registerTask('dev', ['debug','template','couchserver']); - // make a debug install - grunt.registerTask('debug', ['test','dependencies', 'build','template','copy:debug', 'concat:debug']); - // make an install that is server by mochiweb under _utils - grunt.registerTask('couchdebug', ['debug', 'template', 'copy:couchdebug']); - // make an install that can be deployed as a couchapp - grunt.registerTask('couchapp_setup', ['debug', 'template']); - grunt.registerTask('couchdb', ['test', 'dependencies', 'build', 'minify', 'template', 'copy:couchdb']); + grunt.registerTask('minify', ['uglify', 'cssmin:compress']); + + /* + * Build the app in either dev, debug, or release mode + */ + // dev server + grunt.registerTask('dev', ['debug', 'couchserver']); + // build a debug release + grunt.registerTask('debug', ['test', 'dependencies', 'build', 'copy:debug']); // build a release - grunt.registerTask('release', ['test' ,'dependencies', 'build', 'minify','template', 'copy:dist']); + grunt.registerTask('release', ['test' ,'dependencies', 'build', 'minify', 'copy:dist']); + + /* + * Install into CouchDB in either debug, release, or couchapp mode + */ + // make a development install that is server by mochiweb under _utils + grunt.registerTask('couchdebug', ['debug', 'copy:couchdebug']); + // make a minimized install that is server by mochiweb under _utils + grunt.registerTask('couchdb', ['release', 'copy:couchdb']); + // make an install that can be deployed as a couchapp + grunt.registerTask('couchapp_setup', ['build', 'minify', 'copy:dist']); // install fauxton as couchapp grunt.registerTask('couchapp_install', ['rmcouchdb:fauxton', 'mkcouchdb:fauxton', 'couchapp:fauxton']); + // setup and install fauxton as couchapp grunt.registerTask('couchapp_deploy', ['couchapp_setup', 'couchapp_install']); - }; diff --git a/src/fauxton/couchapp.js b/src/fauxton/couchapp.js index 4711ae242..63ea29703 100644 --- a/src/fauxton/couchapp.js +++ b/src/fauxton/couchapp.js @@ -23,5 +23,5 @@ ddoc = { }; -couchapp.loadAttachments(ddoc, path.join(__dirname, 'dist', 'debug')); +couchapp.loadAttachments(ddoc, path.join(__dirname, 'dist', 'release')); module.exports = ddoc; diff --git a/src/fauxton/package.json b/src/fauxton/package.json index 190ee200c..75d7c639f 100644 --- a/src/fauxton/package.json +++ b/src/fauxton/package.json @@ -12,6 +12,7 @@ "grunt-cli": "~0.1.6", "couchapp": "~0.9.1", "grunt-contrib": "~0.5.0", + "grunt-contrib-cssmin": "~0.5.0", "grunt-contrib-uglify": "~0.2.0", "grunt-couchapp": "~0.1.0", "grunt-exec": "~0.4.0", |