-
-
Save dshafik/07dc3985b5f4888865ea to your computer and use it in GitHub Desktop.
Example Gulp/Bower Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"directory": "public/bower_components" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "gulp-bower-example", | |
"version": "0.0.1", | |
"authors": [ | |
"Davey Shafik <davey@engineyard.comm>" | |
], | |
"main": "public/index.php", | |
"license": "Apache 2.0", | |
"private": true, | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
], | |
"dependencies": { | |
"jquery": "~2.1.1", | |
"bootstrap": "~3.1.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
$ = require('gulp-load-plugins')(); // Note the extra parens | |
gulp.task('default', ['minify', 'fix-template', 'fix-paths', 'add-headers']); | |
gulp.task('minify', ['clean'], function() { | |
return gulp.src('src/templates/layout.src.tpl') | |
.pipe($.usemin({ | |
assetsDir: 'public', | |
css: [$.minifyCss(), 'concat'], | |
js: [$.uglify(), 'concat'] | |
})) | |
.pipe(gulp.dest('public')); | |
}); | |
gulp.task('fix-template', ['minify'], function() { | |
return gulp.src('public/layout.src.tpl') | |
.pipe($.rimraf()) | |
.pipe($.rename("layout.tpl")) | |
.pipe(gulp.dest('src/templates')); | |
}); | |
gulp.task('fix-paths', ['minify'], function() { | |
gulp.src('public/css/site.css') | |
.pipe($.replace('../', '../bower_components/bootstrap/dist/')) | |
.pipe(gulp.dest('public/css')); | |
}); | |
gulp.task('add-headers', ['fix-template'], function() { | |
gulp.src('src/templates/layout.tpl') | |
.pipe($.header("<!-- This file is generated — do not edit by hand! -->\n")) | |
.pipe(gulp.dest('src/templates')); | |
gulp.src('public/js/site.js') | |
.pipe($.header("/* This file is generated — do not edit by hand! */\n")) | |
.pipe(gulp.dest('public/js')); | |
gulp.src('public/css/site.css') | |
.pipe($.header("/* This file is generated — do not edit by hand! */\n")) | |
.pipe(gulp.dest('public/css')); | |
}); | |
gulp.task('clean', function() { | |
var generated = ['public/js/site.js', 'public/css/site.css', 'src/templates/layout.tpl']; | |
return gulp.src(generated) | |
.pipe($.rimraf()); | |
}); | |
gulp.task('dev', ['clean'], function() { | |
gulp.src('src/templates/layout.src.tpl') | |
.pipe($.rename('layout.tpl')) | |
.pipe($.header("<!-- This file is generated — do not edit by hand! -->\n")) | |
.pipe(gulp.dest('src/templates')); | |
}); | |
gulp.task('watch', ['default'], function() { | |
var watchFiles = [ | |
'src/templates/layout.src.tpl', | |
'public/bower_components/*/dist/js/*.js', | |
'!public/bower_components/*/dist/js/*.min.js', | |
'public/bower_components/*/dist/*.js', | |
'public/bower_components/*/dist/css/*.css', | |
'!public/bower_components/*/dist/css/*.min.css', | |
'public/bower_components/*/dist/font/*' | |
]; | |
gulp.watch(watchFiles, ['default']); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "gulp-bower-example", | |
"version": "0.0.1", | |
"description": "", | |
"main": "public/index.php", | |
"dependencies": { | |
"bower": "~1.3.5" | |
}, | |
"devDependencies": { | |
"gulp": "^3.8.0", | |
"gulp-minify-css": "^0.3.4", | |
"gulp-usemin": "^0.3.5", | |
"gulp-uglify": "^0.3.0", | |
"gulp-rename": "^1.2.0", | |
"gulp-rimraf": "^0.1.0", | |
"gulp-replace": "^0.3.0", | |
"gulp-header": "^1.0.2" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Davey Shafik <davey@engineyard.com>", | |
"license": "Apache 2.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+5