@@ -11,7 +11,8 @@ var path = require('path'),
1111 convert = require ( 'convert-source-map' ) ,
1212 SourceMapConsumer = require ( 'source-map' ) . SourceMapConsumer ,
1313 mime = require ( 'mime' ) ,
14- crypto = require ( 'crypto' ) ;
14+ crypto = require ( 'crypto' ) ,
15+ defaults = require ( 'lodash.defaults' ) ;
1516
1617/**
1718 * Search for the relative file reference from the <code>startPath</code> up to the process
@@ -124,11 +125,17 @@ function embedRelativeURL(startPath, uri) {
124125 * @param {Array.<string> } [libraryPaths] Any number of library path strings
125126 * @returns {stream.Through } A through stream that performs the operation of a gulp stream
126127 */
127- module . exports = function ( libraryPaths ) {
128+ module . exports = function ( options ) {
129+ defaults ( options , {
130+ libraryPaths : [ ] ,
131+ embedAssets : false
132+ } ) ;
133+
128134 var output = [ ] ,
129- libList = ( libraryPaths || [ ] ) . filter ( function isString ( value ) {
135+ libList = options . libraryPaths . filter ( function isString ( value ) {
130136 return ( typeof value === 'string' ) ;
131137 } ) ;
138+
132139 return through . obj ( function ( file , encoding , done ) {
133140 var stream = this ;
134141
@@ -269,12 +276,13 @@ module.exports = function (libraryPaths) {
269276 ) ;
270277
271278 // rework css
272- var reworked = rework ( cssWithMap , '' )
273- . use ( rewriteUriPlugin ( pushAssetToOutput ) )
274- . toString ( {
275- sourcemap : true ,
276- sourcemapAsObject : true
277- } ) ;
279+ var plugin = rewriteUriPlugin ( options . embedAssets ? embedRelativeURL : pushAssetToOutput ) ,
280+ reworked = rework ( cssWithMap , '' )
281+ . use ( plugin )
282+ . toString ( {
283+ sourcemap : true ,
284+ sourcemapAsObject : true
285+ } ) ;
278286
279287 // adjust overall sourcemap
280288 delete reworked . map . file ;
0 commit comments