1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 20:32:15 -05:00

[WO-724] Optimise grunt build and watch tasks

* add grunt concat step before uglify
* split watch tasks for app and tests
This commit is contained in:
Tankred Hase 2014-11-17 14:29:04 +01:00
parent c85b6344fc
commit aed9d174a5
2 changed files with 185 additions and 144 deletions

View File

@ -34,7 +34,7 @@ module.exports = function(grunt) {
}, },
copy: { copy: {
npmDev: { libTest: {
expand: true, expand: true,
flatten: true, flatten: true,
cwd: './', cwd: './',
@ -218,33 +218,87 @@ module.exports = function(grunt) {
}, },
unitTest: { unitTest: {
files: { files: {
'test/unit/index.browserified.js.map': ['test/unit/index.browserified.js'], 'test/unit/index.js.map': ['test/unit/index.browserified.js'],
} }
}, },
integrationTest: { integrationTest: {
files: { files: {
'test/integration/index.browserified.js.map': ['test/integration/index.browserified.js'], 'test/integration/index.js.map': ['test/integration/index.browserified.js'],
} }
} }
}, },
concat: {
options: {
separator: ';\n',
},
app: {
src: [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/ngtagsinput/ng-tags-input.min.js',
'node_modules/ng-infinite-scroll/build/ng-infinite-scroll.min.js',
'src/lib/fastclick/fastclick.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'dist/js/app.browserified.js'
],
dest: 'dist/js/app.min.js',
},
readSandbox: {
src: [
'node_modules/dompurify/purify.js',
'src/js/controller/read-sandbox.js'
],
dest: 'dist/js/read-sandbox.min.js'
},
pbkdf2Worker: {
src: ['dist/js/pbkdf2-worker.browserified.js'],
dest: 'dist/js/pbkdf2-worker.min.js'
},
mailreaderWorker: {
src: ['dist/js/mailreader-parser-worker.browserified.js'],
dest: 'dist/js/mailreader-parser-worker.min.js'
},
tlsWorker: {
src: ['dist/js/tcp-socket-tls-worker.browserified.js'],
dest: 'dist/js/tcp-socket-tls-worker.min.js'
},
unitTest: {
src: [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/angular/angular-mocks.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'test/unit/index.browserified.js'
],
dest: 'test/unit/index.js'
},
integrationTest: {
src: [
'src/lib/underscore/underscore-min.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'test/integration/index.browserified.js'
],
dest: 'test/integration/index.js'
}
},
uglify: { uglify: {
app: { app: {
files: { files: {
'dist/js/app.min.js': [ 'dist/js/app.min.js': ['dist/js/app.min.js']
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/ngtagsinput/ng-tags-input.min.js',
'node_modules/ng-infinite-scroll/build/ng-infinite-scroll.min.js',
'src/lib/fastclick/fastclick.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'dist/js/app.browserified.js'
]
}, },
options: { options: {
mangle: false, mangle: false,
@ -256,10 +310,7 @@ module.exports = function(grunt) {
}, },
readSandbox: { readSandbox: {
files: { files: {
'dist/js/read-sandbox.min.js': [ 'dist/js/read-sandbox.min.js': ['dist/js/read-sandbox.min.js']
'node_modules/dompurify/purify.js',
'src/js/controller/read-sandbox.js'
]
}, },
options: { options: {
sourceMap: true, sourceMap: true,
@ -268,12 +319,12 @@ module.exports = function(grunt) {
}, },
pbkdf2Worker: { pbkdf2Worker: {
files: { files: {
'dist/js/pbkdf2-worker.min.js': ['dist/js/pbkdf2-worker.browserified.js'] 'dist/js/pbkdf2-worker.min.js': ['dist/js/pbkdf2-worker.min.js']
} }
}, },
mailreaderWorker: { mailreaderWorker: {
files: { files: {
'dist/js/mailreader-parser-worker.min.js': ['dist/js/mailreader-parser-worker.browserified.js'] 'dist/js/mailreader-parser-worker.min.js': ['dist/js/mailreader-parser-worker.min.js']
}, },
options: { options: {
sourceMap: true, sourceMap: true,
@ -282,56 +333,13 @@ module.exports = function(grunt) {
}, },
tlsWorker: { tlsWorker: {
files: { files: {
'dist/js/tcp-socket-tls-worker.min.js': ['dist/js/tcp-socket-tls-worker.browserified.js'] 'dist/js/tcp-socket-tls-worker.min.js': ['dist/js/tcp-socket-tls-worker.min.js']
}, },
options: { options: {
sourceMap: true, sourceMap: true,
sourceMapName: 'dist/js/tcp-socket-tls-worker.min.js.map' sourceMapName: 'dist/js/tcp-socket-tls-worker.min.js.map'
} }
}, },
unitTest: {
files: {
'test/unit/index.js': [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/angular/angular-mocks.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'test/unit/index.browserified.js'
]
},
options: {
mangle: false,
compress: false,
sourceMap: true,
sourceMapIn: 'test/unit/index.browserified.js.map',
sourceMapIncludeSources: true,
sourceMapName: 'test/unit/index.js.map'
}
},
integrationTest: {
files: {
'test/integration/index.js': [
'src/lib/underscore/underscore-min.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'test/integration/index.browserified.js'
]
},
options: {
mangle: false,
compress: false,
sourceMap: true,
sourceMapIn: 'test/integration/index.browserified.js.map',
sourceMapIncludeSources: true,
sourceMapName: 'test/integration/index.js.map'
}
},
options: { options: {
banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n' banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n'
} }
@ -423,9 +431,17 @@ module.exports = function(grunt) {
files: ['src/sass/**/*.scss'], files: ['src/sass/**/*.scss'],
tasks: ['dist-css', 'manifest'] tasks: ['dist-css', 'manifest']
}, },
js: { jsApp: {
files: ['src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'], files: ['src/js/**/*.js'],
tasks: ['dist-js', 'manifest'] tasks: ['dist-js-app']
},
jsUnitTest: {
files: ['test/unit/*-test.js'],
tasks: ['dist-js-unitTest']
},
jsIntegrationTest: {
files: ['test/integration/*-test.js'],
tasks: ['dist-js-integrationTest']
}, },
icons: { icons: {
files: ['src/index.html', 'src/img/icons/*.svg', '!src/img/icons/all.svg'], files: ['src/index.html', 'src/img/icons/*.svg', '!src/img/icons/all.svg'],
@ -489,6 +505,7 @@ module.exports = function(grunt) {
// Load the plugin(s) // Load the plugin(s)
grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
@ -509,7 +526,30 @@ module.exports = function(grunt) {
// Build tasks // Build tasks
grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']); grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
grunt.registerTask('dist-js', ['browserify', 'exorcise', 'uglify']); grunt.registerTask('dist-js', ['browserify', 'exorcise', 'concat', 'uglify']);
grunt.registerTask('dist-js-app', [
'browserify:app',
'browserify:pbkdf2Worker',
'browserify:mailreaderWorker',
'browserify:tlsWorker',
'exorcise:app',
'concat:app',
'concat:readSandbox',
'concat:pbkdf2Worker',
'concat:mailreaderWorker',
'concat:tlsWorker',
'manifest'
]);
grunt.registerTask('dist-js-unitTest', [
'browserify:unitTest',
'exorcise:unitTest',
'concat:unitTest',
]);
grunt.registerTask('dist-js-integrationTest', [
'browserify:integrationTest',
'exorcise:integrationTest',
'concat:integrationTest',
]);
grunt.registerTask('dist-copy', ['copy']); grunt.registerTask('dist-copy', ['copy']);
grunt.registerTask('dist-assets', ['svgmin', 'svgstore', 'string-replace']); grunt.registerTask('dist-assets', ['svgmin', 'svgstore', 'string-replace']);
grunt.registerTask('dist', ['clean:dist', 'shell', 'dist-css', 'dist-js', 'dist-assets', 'dist-copy', 'manifest']); grunt.registerTask('dist', ['clean:dist', 'shell', 'dist-css', 'dist-js', 'dist-assets', 'dist-copy', 'manifest']);

View File

@ -1,74 +1,75 @@
{ {
"name": "whiteout-mail", "name": "whiteout-mail",
"description": "Mail App with integrated OpenPGP encryption.", "description": "Mail App with integrated OpenPGP encryption.",
"author": "Whiteout Networks", "author": "Whiteout Networks",
"homepage": "https://whiteout.io", "homepage": "https://whiteout.io",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/whiteout-io/mail-html5.git" "url": "https://github.com/whiteout-io/mail-html5.git"
}, },
"keywords": [ "keywords": [
"email", "email",
"mail", "mail",
"client", "client",
"app", "app",
"openpgp", "openpgp",
"pgp", "pgp",
"gpg", "gpg",
"imap", "imap",
"smtp" "smtp"
], ],
"engines": { "engines": {
"node": ">=0.10" "node": ">=0.10"
}, },
"scripts": { "scripts": {
"test": "grunt && grunt test", "test": "grunt && grunt test",
"start": "node server.js" "start": "node server.js"
}, },
"dependencies": { "dependencies": {
"compression": "^1.0.11", "compression": "^1.0.11",
"config": "^1.0.2", "config": "^1.0.2",
"express": "^4.8.3", "express": "^4.8.3",
"morgan": "^1.2.3", "morgan": "^1.2.3",
"npmlog": "^0.1.1", "npmlog": "^0.1.1",
"socket.io": "^1.0.6" "socket.io": "^1.0.6"
}, },
"devDependencies": { "devDependencies": {
"axe-logger": "~0.0.2", "axe-logger": "~0.0.2",
"crypto-lib": "~0.2.1", "browsercrow": "https://github.com/whiteout-io/browsercrow/tarball/master",
"dompurify": "~0.4.2", "browsersmtp": "https://github.com/whiteout-io/browsersmtp/tarball/master",
"imap-client": "~0.7.0", "chai": "~1.9.2",
"jquery": "~2.1.1", "crypto-lib": "~0.2.1",
"mailreader": "~0.4.0", "dompurify": "~0.4.2",
"ng-infinite-scroll": "~1.1.2", "grunt": "~0.4.1",
"pgpbuilder": "~0.5.0", "grunt-autoprefixer": "~0.7.2",
"pgpmailer": "~0.7.0", "grunt-browserify": "^3.0.1",
"tcp-socket": "~0.4.0", "grunt-contrib-clean": "~0.5.0",
"wo-smtpclient": "~0.5.0", "grunt-contrib-compress": "~0.5.2",
"browsercrow": "https://github.com/whiteout-io/browsercrow/tarball/master", "grunt-contrib-concat": "^0.5.0",
"browsersmtp": "https://github.com/whiteout-io/browsersmtp/tarball/master", "grunt-contrib-connect": "~0.5.0",
"chai": "~1.9.2", "grunt-contrib-copy": "~0.4.1",
"grunt": "~0.4.1", "grunt-contrib-jshint": "~0.6.4",
"grunt-browserify": "^3.0.1", "grunt-contrib-sass": "~0.7.3",
"grunt-contrib-clean": "~0.5.0", "grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-copy": "~0.4.1", "grunt-contrib-watch": "~0.5.3",
"grunt-manifest": "^0.4.0", "grunt-csso": "~0.6.1",
"grunt-autoprefixer": "~0.7.2", "grunt-exorcise": "^0.2.0",
"grunt-contrib-compress": "~0.5.2", "grunt-manifest": "^0.4.0",
"grunt-contrib-connect": "~0.5.0", "grunt-mocha-phantomjs": "^0.6.0",
"grunt-contrib-jshint": "~0.6.4", "grunt-shell": "~1.1.1",
"grunt-contrib-sass": "~0.7.3", "grunt-string-replace": "~1.0.0",
"grunt-contrib-uglify": "^0.6.0", "grunt-svgmin": "~1.0.0",
"grunt-contrib-watch": "~0.5.3", "grunt-svgstore": "~0.3.4",
"grunt-shell": "~1.1.1", "imap-client": "~0.7.0",
"grunt-csso": "~0.6.1", "jquery": "~2.1.1",
"grunt-exorcise": "^0.2.0", "mailreader": "~0.4.0",
"grunt-mocha-phantomjs": "^0.6.0", "mocha": "^1.21.4",
"mocha": "^1.21.4", "ng-infinite-scroll": "~1.1.2",
"sinon": "~1.7.3", "pgpbuilder": "~0.5.0",
"time-grunt": "^1.0.0", "pgpmailer": "~0.7.0",
"grunt-string-replace": "~1.0.0", "sinon": "~1.7.3",
"grunt-svgmin": "~1.0.0", "tcp-socket": "~0.4.0",
"grunt-svgstore": "~0.3.4" "time-grunt": "^1.0.0",
} "wo-smtpclient": "~0.5.0"
}
} }