Wenqer / gulp-base64

Gulp task for converting all data found within a stylesheet (those within a url( ... ) declaration) into base64-encoded data URI strings
MIT License
125 stars 24 forks source link

Directory condition to convert images #26

Open fredw opened 8 years ago

fredw commented 8 years ago

Is there any way to define a condition to only convert urls from a specific directory? Actually I'm using grunt-data-uri plugin from Grunt that allow to define this condition, but I'm starting to use Gulp tasks. The Grunt plugin is configured in this way:

grunt.config('dataUri', {
    default: {
        src: ['public/css/*.css'],
        dest: 'public/css/',
        options: {
            target: ['public/images/inline-data/**']
        }
    }
});

The plugin converts only to base64 the images that are loaded from public/images/inline-data/*. If the image is loaded from a directory different from this, the plugin doesn't replace the url(image) to base64.

dobesv commented 7 years ago

You could use the exclude regex filter to do this probably, with a regex that matches anything NOT in that folder (e.g. negative lookahead).