diff --git a/gulpfile.js b/gulpfile.js index c93a426..839b7df 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,30 +18,33 @@ var paths = { } -var bowerFilesMinified = mainBowerFiles({ - overrides : { - jquery : { - main: [] - }, - bootstrap : { - main: [ "dist/**/*.css" ] - } - } -}).map(function(path, index,arr) { - var newPath = path.replace(/.([^.]+)$/g, '.min.$1'); - return exists ( newPath ) ? newPath : path; -}) +pipes.bowerFiles = function() { + return gulp.src(mainBowerFiles({ + overrides : { + jquery : { + main: [] + }, + bootstrap : { + main: [ + "dist/**/*.min.css", + './dist/fonts/*.*' + ] + } + } + }),{base: 'webapp/bower_components'}) + .pipe(plugins.debug({title:'bower-file'})); +} -var bowerFiles = mainBowerFiles({ - overrides : { - jquery : { - main: [] - }, - bootstrap : { - main: [ "dist/**/*.css" ] - } - } -}) +pipes.bowerFilesMinified = function() { + return pipes.bowerFiles() + .pipe(plugins.rename(function (path) { + testpath = 'webapp/bower_components/' + path.dirname + '/' + path.basename + '.min' + path.extname; + if (exists(testpath)) { + path.extname = '.min' + path.extname; + } + })) + .pipe(plugins.debug({title: 'bower-file-minimized:'})); +} pipes.validatedAppScripts = function() { return gulp.src(paths.appFiles) @@ -50,19 +53,25 @@ pipes.validatedAppScripts = function() { } pipes.validatedIndex = function() { - return gulp.src(paths.index); + return gulp.src(paths.index) + .pipe(plugins.htmlhint()) + .pipe(plugins.htmlhint.reporter()); } pipes.validatedPartials = function() { - return gulp.src(paths.partials); + return gulp.src(paths.partials) + .pipe(plugins.htmlhint({'doctype-first': false})) + .pipe(plugins.htmlhint.reporter()); } pipes.validatedPages = function() { return gulp.src(paths.pages) + .pipe(plugins.htmlhint({'doctype-first': false})) + .pipe(plugins.htmlhint.reporter()); } pipes.builtIndexDev = function() { - var vendorFiles = gulp.src(bowerFilesMinified) + var vendorFiles = pipes.bowerFilesMinified() .pipe(gulp.dest(paths.distDev + '/vendor')); var appScript = pipes.validatedAppScripts() .pipe(plugins.angularFilesort()) @@ -84,6 +93,46 @@ pipes.builtIndexDev = function() { } +pipes.builtIndexProd = function() { + var filterJS = plugins.filter('**/*.js',{restore: true}); + var vendorFiles = pipes.bowerFiles() + .pipe(filterJS) + .pipe(plugins.debug({title:'non-minified-vendor:'})) + .pipe(plugins.concat('vendor.min.js')) + .pipe(plugins.uglify()) + .pipe(filterJS.restore) + .pipe(gulp.dest(paths.distProd + '/vendor')); + + + + var appScript = pipes.validatedAppScripts() + .pipe(plugins.angularFilesort()) + .pipe(plugins.ngAnnotate()) + .pipe(plugins.concat('app.min.js')) + .pipe(plugins.uglify()) + .pipe(gulp.dest(paths.distProd + '/js')); + + var appStyle = gulp.src(paths.cssFiles) + .pipe(plugins.minifyCss()) + .pipe(plugins.rename(function (path) { + path.extname = '.min'+ path.extname; + })) + .pipe(gulp.dest(paths.distProd + '/css')) + + var partials = pipes.validatedPartials() + .pipe(gulp.dest(paths.distProd + '/js')) + + var pages = pipes.validatedPages() + .pipe(gulp.dest(paths.distProd + '/html')) + + return pipes.validatedIndex() + .pipe(plugins.inject(vendorFiles, {ignorePath: '/' + paths.distProd, name : 'bower'})) + .pipe(plugins.inject(es.merge(appStyle,partials,pages), {ignorePath: '/' + paths.distProd})) + .pipe(plugins.inject(appScript, {ignorePath: '/' + paths.distProd})) + .pipe(gulp.dest(paths.distProd)); + +} + gulp.task('test', function(done) { server = new karma.Server({ @@ -99,3 +148,5 @@ gulp.task('test', function(done) { gulp.task('build-dev', pipes.builtIndexDev); + +gulp.task('build-prod', pipes.builtIndexProd); diff --git a/package.json b/package.json index a9c3ea6..0891d8f 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,20 @@ "bower": "^1.7.7", "gulp": "^3.9.1", "gulp-angular-filesort": "^1.1.1", + "gulp-concat": "^2.6.0", "gulp-debug": "^2.1.2", + "gulp-filter": "^3.0.1", + "gulp-htmlhint": "^0.3.1", + "gulp-htmlmin": "^1.3.0", "gulp-inject": "^3.0.0", "gulp-jasmine": "^2.2.1", "gulp-jshint": "^2.0.0", "gulp-karma": "0.0.5", "gulp-load-plugins": "^1.2.0", + "gulp-minify-css": "^1.2.3", + "gulp-ng-annotate": "^1.1.0", "gulp-rename": "^1.2.2", + "gulp-uglify": "^1.5.3", "gulp-util": "^3.0.7", "jasmine-core": "^2.4.1", "jshint": "^2.9.1", diff --git a/webapp/js/services.js b/webapp/js/services.js index ef52dc4..a2cf8e8 100644 --- a/webapp/js/services.js +++ b/webapp/js/services.js @@ -6,11 +6,11 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) { var removeSerie = /^\(.*\) .*$/; function cleanupName(name) { - matches = name.match(determinantRegexp); - if (matches == null) { + var matchesStr = name.match(determinantRegexp); + if (matchesStr == null) { return name; } - return matches[2] + ' ' + matches[1]; + return matchesStr[2] + ' ' + matchesStr[1]; } function cleanupFields(album) {