1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 02:42:17 -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: {
npmDev: {
libTest: {
expand: true,
flatten: true,
cwd: './',
@ -218,20 +218,22 @@ module.exports = function(grunt) {
},
unitTest: {
files: {
'test/unit/index.browserified.js.map': ['test/unit/index.browserified.js'],
'test/unit/index.js.map': ['test/unit/index.browserified.js'],
}
},
integrationTest: {
files: {
'test/integration/index.browserified.js.map': ['test/integration/index.browserified.js'],
'test/integration/index.js.map': ['test/integration/index.browserified.js'],
}
}
},
uglify: {
concat: {
options: {
separator: ';\n',
},
app: {
files: {
'dist/js/app.min.js': [
src: [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
@ -244,7 +246,59 @@ module.exports = function(grunt) {
'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: {
app: {
files: {
'dist/js/app.min.js': ['dist/js/app.min.js']
},
options: {
mangle: false,
@ -256,10 +310,7 @@ module.exports = function(grunt) {
},
readSandbox: {
files: {
'dist/js/read-sandbox.min.js': [
'node_modules/dompurify/purify.js',
'src/js/controller/read-sandbox.js'
]
'dist/js/read-sandbox.min.js': ['dist/js/read-sandbox.min.js']
},
options: {
sourceMap: true,
@ -268,12 +319,12 @@ module.exports = function(grunt) {
},
pbkdf2Worker: {
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: {
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: {
sourceMap: true,
@ -282,56 +333,13 @@ module.exports = function(grunt) {
},
tlsWorker: {
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: {
sourceMap: true,
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: {
banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n'
}
@ -423,9 +431,17 @@ module.exports = function(grunt) {
files: ['src/sass/**/*.scss'],
tasks: ['dist-css', 'manifest']
},
js: {
files: ['src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'],
tasks: ['dist-js', 'manifest']
jsApp: {
files: ['src/js/**/*.js'],
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: {
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)
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
@ -509,7 +526,30 @@ module.exports = function(grunt) {
// Build tasks
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-assets', ['svgmin', 'svgstore', 'string-replace']);
grunt.registerTask('dist', ['clean:dist', 'shell', 'dist-css', 'dist-js', 'dist-assets', 'dist-copy', 'manifest']);

View File

@ -35,40 +35,41 @@
},
"devDependencies": {
"axe-logger": "~0.0.2",
"crypto-lib": "~0.2.1",
"dompurify": "~0.4.2",
"imap-client": "~0.7.0",
"jquery": "~2.1.1",
"mailreader": "~0.4.0",
"ng-infinite-scroll": "~1.1.2",
"pgpbuilder": "~0.5.0",
"pgpmailer": "~0.7.0",
"tcp-socket": "~0.4.0",
"wo-smtpclient": "~0.5.0",
"browsercrow": "https://github.com/whiteout-io/browsercrow/tarball/master",
"browsersmtp": "https://github.com/whiteout-io/browsersmtp/tarball/master",
"chai": "~1.9.2",
"crypto-lib": "~0.2.1",
"dompurify": "~0.4.2",
"grunt": "~0.4.1",
"grunt-autoprefixer": "~0.7.2",
"grunt-browserify": "^3.0.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-manifest": "^0.4.0",
"grunt-autoprefixer": "~0.7.2",
"grunt-contrib-compress": "~0.5.2",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-sass": "~0.7.3",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-shell": "~1.1.1",
"grunt-csso": "~0.6.1",
"grunt-exorcise": "^0.2.0",
"grunt-manifest": "^0.4.0",
"grunt-mocha-phantomjs": "^0.6.0",
"mocha": "^1.21.4",
"sinon": "~1.7.3",
"time-grunt": "^1.0.0",
"grunt-shell": "~1.1.1",
"grunt-string-replace": "~1.0.0",
"grunt-svgmin": "~1.0.0",
"grunt-svgstore": "~0.3.4"
"grunt-svgstore": "~0.3.4",
"imap-client": "~0.7.0",
"jquery": "~2.1.1",
"mailreader": "~0.4.0",
"mocha": "^1.21.4",
"ng-infinite-scroll": "~1.1.2",
"pgpbuilder": "~0.5.0",
"pgpmailer": "~0.7.0",
"sinon": "~1.7.3",
"tcp-socket": "~0.4.0",
"time-grunt": "^1.0.0",
"wo-smtpclient": "~0.5.0"
}
}