log('Wiring bower dependencies into karma.conf.js');
var wiredep = require('wiredep').stream;
- var jsFiles = args.stubs ? [].concat(config.jsFilesWithoutSpecs, config.jsFilesStubs) : config.jsFilesWithoutSpecs;
return gulp.src(config.karmaConf)
.pipe(wiredep(config.getWiredepKarmaOptions()))
});
/**
+ * Builds application.
+ *
+ * @returns {stream} The stream.
+ */
+gulp.task('build', ['wiredep', 'test'], function() {
+ log('Building application.');
+
+ var assets = plugins.useref.assets({searchPath: './'});
+ // Filters are named for the gulp-useref path
+ var cssFilter = plugins.filter('**/*.css');
+ var jsAppFilter = plugins.filter('**/' + config.build.app);
+ var jslibFilter = plugins.filter('**/' + config.build.lib);
+
+ return gulp.src(config.index)
+ // Gather all assets from the html with useref
+ .pipe(assets)
+ // Get the css
+ .pipe(cssFilter)
+ .pipe(plugins.minifyCss())
+ .pipe(cssFilter.restore())
+ // Get the custom javascript
+ .pipe(jsAppFilter)
+ .pipe(plugins.ngAnnotate({add: true}))
+ .pipe(plugins.uglify({
+ compress: {
+ //jscs:disable
+ drop_console: true, // jshint ignore:line
+ drop_debugger: true // jshint ignore:line
+ //jscs:enable
+ }
+ }))
+ .pipe(getHeader())
+ .pipe(jsAppFilter.restore())
+ // Get the vendor javascript
+ .pipe(jslibFilter)
+ .pipe(plugins.uglify())
+ .pipe(jslibFilter.restore())
+ // Take inventory of the file names for future rev numbers
+ .pipe(plugins.rev())
+ // Apply the concat and file replacement with useref
+ .pipe(assets.restore())
+ .pipe(plugins.useref())
+ // Replace the file names in the html with rev numbers
+ .pipe(plugins.revReplace())
+ .pipe(gulp.dest(config.build.directory));
+
+ /**
+ * Format and return the header for files
+ *
+ * @return {stream} The stream.
+ */
+ function getHeader() {
+ var pkg = require('./package.json');
+ var banner = ['/**',
+ ' * <%= pkg.name %> - <%= pkg.description %>',
+ ' * @authors <%= pkg.authors %>',
+ ' * @version v<%= pkg.version %>',
+ ' * @link <%= pkg.homepage %>',
+ ' * @license <%= pkg.license %>',
+ ' */',
+ ''
+ ].join('\n');
+ return plugins.header(banner, {pkg: pkg});
+ }
+
+});
+
+/**
* Inject files in a sorted sequence at a specified inject label.
*
* @param {Array} source Source files (glob patterns)
* @param {string=} label The label name to be used by gulp-inject.
- * @returns {Stream} The stream.
+ * @returns {stream} The stream.
*/
function inject(source, label) {
var options = {relative: false};
"name": "showcase",
"version": "0.0.1",
"description": "My showcase module",
+ "author": {
+ "name": "Gustavo Martin Morcuende",
+ "email": "noemail@noemail.invalid",
+ "url": "http://gumartinm.name"
+ },
+ "homepage": "http://gumartinm.name",
+ "license": "Apache License, Version 2.0",
"devDependencies": {
"express": "~4.13.3",
"express-http-proxy": "~0.6.0",
"gulp": "~3.9.0",
"gulp-angular-filesort": "~1.1.1",
+ "gulp-filter": "~3.0.0",
+ "gulp-header": "~1.2.2",
"gulp-if": "~1.2.5",
"gulp-inject": "~1.5.0",
"gulp-jscs": "~2.0.0",
"gulp-jshint": "~1.11.2",
"gulp-load-plugins": "~1.0.0-rc.1",
+ "gulp-minify-css": "~1.2.0",
+ "gulp-ng-annotate": "~1.1.0",
"gulp-nodemon": "~2.0.3",
"gulp-order": "~1.1.1",
"gulp-print": "~1.1.0",
+ "gulp-rev": "~5.1.0",
+ "gulp-rev-replace": "~0.4.2",
"gulp-task-listing": "~1.0.1",
+ "gulp-uglify": "~1.2.0",
"gulp-useref": "~1.3.0",
"gulp-util": "~3.0.6",
"jshint-stylish": "~2.0.1",
"yargs": "~3.19.0"
},
"scripts": {
- "pretest": "wiredep -s karma.conf.js --dependencies --devDependencies",
"test": "gulp test",
"postinstall": "bower install --force-latest"
}