diff --git a/bower.json b/bower.json index 7c4c8ca223..11f82fd6b5 100644 --- a/bower.json +++ b/bower.json @@ -14,5 +14,17 @@ "angular-ui-router": "~0.2.18", "bootstrap": "~3.3.6", "owasp-password-strength-test": "~1.3.0" + }, + "overrides": { + "bootstrap": { + "main": [ + "dist/css/bootstrap.css", + "dist/css/bootstrap-theme.css", + "less/bootstrap.less" + ] + }, + "jquery": { + "main": [] + } } } diff --git a/config/assets/default.js b/config/assets/default.js index 6f6426cd41..38f0b2487c 100644 --- a/config/assets/default.js +++ b/config/assets/default.js @@ -4,10 +4,13 @@ module.exports = { client: { lib: { css: [ + // bower:css 'public/lib/bootstrap/dist/css/bootstrap.css', 'public/lib/bootstrap/dist/css/bootstrap-theme.css' + // endbower ], js: [ + // bower:js 'public/lib/angular/angular.js', 'public/lib/angular-resource/angular-resource.js', 'public/lib/angular-animate/angular-animate.js', @@ -16,6 +19,7 @@ module.exports = { 'public/lib/angular-bootstrap/ui-bootstrap-tpls.js', 'public/lib/angular-file-upload/dist/angular-file-upload.js', 'public/lib/owasp-password-strength-test/owasp-password-strength-test.js' + // endbower ], tests: ['public/lib/angular-mocks/angular-mocks.js'] }, diff --git a/config/assets/production.js b/config/assets/production.js index c151fb5fa6..79cfe745ba 100644 --- a/config/assets/production.js +++ b/config/assets/production.js @@ -4,10 +4,13 @@ module.exports = { client: { lib: { css: [ + // bower:css 'public/lib/bootstrap/dist/css/bootstrap.min.css', 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css', + // endbower ], js: [ + // bower:js 'public/lib/angular/angular.min.js', 'public/lib/angular-resource/angular-resource.min.js', 'public/lib/angular-animate/angular-animate.min.js', @@ -16,6 +19,7 @@ module.exports = { 'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js', 'public/lib/angular-file-upload/dist/angular-file-upload.min.js', 'public/lib/owasp-password-strength-test/owasp-password-strength-test.js' + // endbower ] }, css: 'public/dist/application.min.css', diff --git a/gulpfile.js b/gulpfile.js index f1a9cde628..567217c347 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -215,6 +215,48 @@ gulp.task('imagemin', function () { .pipe(gulp.dest('public/dist/img')); }); +// wiredep task to default +gulp.task('wiredep', function () { + return gulp.src('config/assets/default.js') + .pipe(plugins.wiredep({ + ignorePath: '../../' + })) + .pipe(gulp.dest('config/assets/')); +}); + +// wiredep task to production +gulp.task('wiredep:prod', function () { + return gulp.src('config/assets/production.js') + .pipe(plugins.wiredep({ + ignorePath: '../../', + fileTypes: { + js: { + replace: { + css: function (filePath) { + var minFilePath = filePath.replace('.css', '.min.css'); + var fullPath = path.join(process.cwd(), minFilePath); + if (!fs.existsSync(fullPath)) { + return '\'' + filePath + '\','; + } else { + return '\'' + minFilePath + '\','; + } + }, + js: function (filePath) { + var minFilePath = filePath.replace('.js', '.min.js'); + var fullPath = path.join(process.cwd(), minFilePath); + if (!fs.existsSync(fullPath)) { + return '\'' + filePath + '\','; + } else { + return '\'' + minFilePath + '\','; + } + } + } + } + } + })) + .pipe(gulp.dest('config/assets/')); +}); + // Copy local development environment config example gulp.task('copyLocalEnvConfig', function () { var src = []; @@ -339,7 +381,7 @@ gulp.task('lint', function (done) { // Lint project files and minify them into two production files. gulp.task('build', function (done) { - runSequence('env:dev', 'lint', ['uglify', 'cssmin'], done); + runSequence('env:dev', 'wiredep:prod', 'lint', ['uglify', 'cssmin'], done); }); // Run the project tests diff --git a/package.json b/package.json index 62167bb6eb..37327048ec 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "lodash": "~4.3.0", "lusca": "~1.3.0", "method-override": "~2.3.5", + "gulp-wiredep": "~0.0.0", "mocha": "~2.4.5", "mongoose": "~4.4.3", "morgan": "~1.6.1",