Last active
November 20, 2018 13:07
-
-
Save vincent-zurczak/424c5d136063c120ee18 to your computer and use it in GitHub Desktop.
Copy minified Bower dependencies with Gulp (better solution)
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
// 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