diff --git a/Gruntfile.js b/Gruntfile.js index 53942da0b..55afb060a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,28 +5,54 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-markdown'); grunt.loadNpmTasks('grunt-shell'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); // Project Configuration grunt.initConfig({ shell: { - browserify: { + prod: { + options: { + stdout: false, + stderr: false + }, + command: 'node ./util/build.js' + }, + dev: { options: { stdout: true, stderr: true }, - command: grunt.option('target') === 'dev' ? - 'node ./util/build.js -d ' : 'node ./util/build.js ' + command: 'node ./util/build.js -d' } }, watch: { + options: { + dateFormat: function(time) { + grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString()); + grunt.log.writeln('Waiting for more changes...'); + }, + }, readme: { files: ['README.md'], tasks: ['markdown'] }, scripts: { - files: ['*.js', '*/*/*.js', '**/*.js', '*.html', '!**/node_modules/**', '!lib/**js', '!browser/vendor-bundle.js', '!js/copayBundle.js'], - tasks: ['shell'], + files: [ + 'js/models/**/*.js', + '!*.html', + '!**/node_modules/**', + '!lib/**js', + '!browser/vendor-bundle.js', + '!js/copayBundle.js' + ], + tasks: ['shell'] }, + css: { + files: ['css/src/*.css'], + tasks: ['cssmin'] + } }, mochaTest: { options: { @@ -43,9 +69,70 @@ module.exports = function(grunt) { ext: '.html' }] } + }, + concat: { + vendors: { + src: [ + 'lib/moment/min/moment.min.js', + 'lib/qrcode-generator/js/qrcode.js', + 'lib/peer.js', + 'lib/bitcore.js', + 'lib/crypto-js/rollups/sha256.js', + 'lib/crypto-js/rollups/pbkdf2.js', + 'lib/crypto-js/rollups/aes.js', + 'lib/file-saver/FileSaver.js', + 'lib/socket.io-client/socket.io.js', + 'lib/sjcl.js', + 'lib/ios-imagefile-megapixel/megapix-image.js', + 'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js' + ], + dest: 'lib/vendors.js' + }, + angular: { + src: [ + 'lib/angular/angular.min.js', + 'lib/angular-route/angular-route.min.js', + 'lib/angular-moment/angular-moment.js', + 'lib/angular-qrcode/qrcode.js', + 'lib/ng-idle/angular-idle.min.js', + 'lib/angular-foundation/mm-foundation.min.js', + 'lib/angular-foundation/mm-foundation-tpls.min.js' + ], + dest: 'lib/angularjs-all.js' + }, + main: { + src: [ + 'js/app.js', + 'js/directives.js', + 'js/filters.js', + 'js/routes.js', + 'js/services/*.js', + 'js/controllers/*.js' + ], + dest: 'js/copayMain.js' + } + }, + cssmin: { + combine: { + files: { + 'css/copay.min.css': ['css/src/*.css'], + 'css/vendors.min.css': ['css/foundation.min.css', 'css/foundation-icons.css', 'lib/angular/angular-csp.css'] + } + } + }, + uglify: { + options: { + mangle: false + }, + prod: { + files: { + 'js/copayMain.js': ['js/copayMain.js'] + } + } } }); - grunt.registerTask('default', ['shell', 'watch']); + grunt.registerTask('default', ['shell:dev', 'concat', 'cssmin']); + grunt.registerTask('prod', ['shell:prod', 'concat', 'cssmin', 'uglify']); }; diff --git a/index.html b/index.html index 848b2d4b0..f3a30b346 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,8 @@ Copay - Multisignature Wallet - - - - - + + @@ -60,59 +57,13 @@ - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/package.json b/package.json index cc4487302..97ce1a198 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,9 @@ "express": "4.0.0", "github-releases": "0.2.0", "grunt-browserify": "2.0.8", + "grunt-contrib-concat": "0.5.0", + "grunt-contrib-cssmin": "0.10.0", + "grunt-contrib-uglify": "^0.5.1", "grunt-contrib-watch": "0.5.3", "grunt-markdown": "0.5.0", "browser-pack": "2.0.1",