Enhance Gulp dependency compilation

Gulp automatically grabs all of the dependencies listed as main files in
`bower.json` except for jQuery and modernizr

Deletes plugin directory, bad development pattern. Doesn't make sense
with the existence of `vendor` directory anyway.

Concat all of the js in the js directory except vendor and compiled
files
This commit is contained in:
Austin Pray
2014-09-11 23:04:29 -05:00
parent 45a00cec0e
commit 6e0e036ae7
4 changed files with 31 additions and 17 deletions

View File

@@ -17,5 +17,23 @@
"jquery": "1.11.1",
"bootstrap": "3.2.0",
"respond": "1.4.2"
},
"overrides": {
"bootstrap": {
"main": [
"./js/transition.js",
"./js/alert.js",
"./js/button.js",
"./js/carousel.js",
"./js/collapse.js",
"./js/dropdown.js",
"./js/modal.js",
"./js/tooltip.js",
"./js/popover.js",
"./js/scrollspy.js",
"./js/tab.js",
"./js/affix.js"
]
}
}
}

View File

@@ -1,23 +1,13 @@
/*global $:true*/
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
var paths = {
scripts: [
'assets/vendor/bootstrap/js/transition.js',
'assets/vendor/bootstrap/js/alert.js',
'assets/vendor/bootstrap/js/button.js',
'assets/vendor/bootstrap/js/carousel.js',
'assets/vendor/bootstrap/js/collapse.js',
'assets/vendor/bootstrap/js/dropdown.js',
'assets/vendor/bootstrap/js/modal.js',
'assets/vendor/bootstrap/js/tooltip.js',
'assets/vendor/bootstrap/js/popover.js',
'assets/vendor/bootstrap/js/scrollspy.js',
'assets/vendor/bootstrap/js/tab.js',
'assets/vendor/bootstrap/js/affix.js',
'assets/js/plugins/*.js',
'assets/js/_*.js'
'assets/js/**/*.js',
'!assets/js/vendor/**/*',
'!assets/js/scripts*.js'
],
jshint: [
'gulpfile.js',
@@ -26,7 +16,8 @@ var paths = {
'!assets/js/scripts.min.js',
'!assets/**/*.min-*'
],
less: 'assets/less/main.less'
less: 'assets/less/main.less',
bower: mainBowerFiles()
};
var destination = {
@@ -38,6 +29,7 @@ var destination = {
gulp.task('less', function() {
return gulp.src(paths.less)
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.less()).on('error', function(err) {
console.warn(err.message);
@@ -60,7 +52,8 @@ gulp.task('jshint', function() {
});
gulp.task('js', ['jshint'], function() {
return gulp.src(paths.scripts)
return gulp.src(paths.bower.concat(paths.scripts))
.pipe($.filter(['**/*.js', '!jquery.js', '!modernizr.js']))
.pipe($.concat('./scripts.js'))
.pipe(gulp.dest(destination.scripts))
.pipe($.uglify())

View File

@@ -27,6 +27,7 @@
"gulp": "^3.8.7",
"gulp-autoprefixer": "^0.0.7",
"gulp-concat": "^2.3.4",
"gulp-filter": "^0.5.0",
"gulp-grunt": "^0.5.2",
"gulp-jshint": "^1.8.4",
"gulp-less": "^1.3.3",
@@ -34,10 +35,12 @@
"gulp-load-plugins": "^0.5.0",
"gulp-minify-css": "^0.3.7",
"gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop",
"gulp-plumber": "^0.6.3",
"gulp-rename": "^1.2.0",
"gulp-rev": "^1.1.0",
"gulp-sourcemaps": "^1.1.1",
"gulp-uglify": "^0.3.1",
"jshint-stylish": "^0.4.0"
"jshint-stylish": "^0.4.0",
"main-bower-files": "^1.0.1"
}
}