Skip to content

Instantly share code, notes, and snippets.

@vincent-zurczak
Last active November 20, 2018 13:07
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save vincent-zurczak/424c5d136063c120ee18 to your computer and use it in GitHub Desktop.
Save vincent-zurczak/424c5d136063c120ee18 to your computer and use it in GitHub Desktop.
Copy minified Bower dependencies with Gulp (better solution)
// Include our plug-ins
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var exists = require('path-exists').sync;
// Create some task
gulp.task( 'copy-bower-dep', function() {
// Replace files by their minified version when possible
var bowerWithMin = mainBowerFiles().map( function(path, index, arr) {
var newPath = path.replace(/.([^.]+)$/g, '.min.$1');
return exists( newPath ) ? newPath : path;
});
// Copy them to another directory
gulp.src( bowerWithMin ).pipe( gulp.dest( './target/dist/lib' ));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment