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", "jquery": "1.11.1",
"bootstrap": "3.2.0", "bootstrap": "3.2.0",
"respond": "1.4.2" "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*/ /*global $:true*/
var gulp = require('gulp'); var gulp = require('gulp');
var $ = require('gulp-load-plugins')(); var $ = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
var paths = { var paths = {
scripts: [ scripts: [
'assets/vendor/bootstrap/js/transition.js', 'assets/js/**/*.js',
'assets/vendor/bootstrap/js/alert.js', '!assets/js/vendor/**/*',
'assets/vendor/bootstrap/js/button.js', '!assets/js/scripts*.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'
], ],
jshint: [ jshint: [
'gulpfile.js', 'gulpfile.js',
@@ -26,7 +16,8 @@ var paths = {
'!assets/js/scripts.min.js', '!assets/js/scripts.min.js',
'!assets/**/*.min-*' '!assets/**/*.min-*'
], ],
less: 'assets/less/main.less' less: 'assets/less/main.less',
bower: mainBowerFiles()
}; };
var destination = { var destination = {
@@ -38,6 +29,7 @@ var destination = {
gulp.task('less', function() { gulp.task('less', function() {
return gulp.src(paths.less) return gulp.src(paths.less)
.pipe($.plumber())
.pipe($.sourcemaps.init()) .pipe($.sourcemaps.init())
.pipe($.less()).on('error', function(err) { .pipe($.less()).on('error', function(err) {
console.warn(err.message); console.warn(err.message);
@@ -60,7 +52,8 @@ gulp.task('jshint', function() {
}); });
gulp.task('js', ['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($.concat('./scripts.js'))
.pipe(gulp.dest(destination.scripts)) .pipe(gulp.dest(destination.scripts))
.pipe($.uglify()) .pipe($.uglify())

View File

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