asset-builder icon indicating copy to clipboard operation
asset-builder copied to clipboard

SVG images ending up under fonts

Open JvanderHeide opened this issue 9 years ago • 6 comments

Using a bower plugin. SVG image could not be found because it appears in globs.fonts instead of globs.images. Anyway to make sure only SVG fonts go to fonts and SVG images go to images?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/13492928-svg-images-ending-up-under-fonts?utm_campaign=plugin&utm_content=tracker%2F8853550&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F8853550&utm_medium=issues&utm_source=github).

JvanderHeide avatar May 07 '15 14:05 JvanderHeide

For now I'm using this work around, although it's not ideal. And the .SVG still ends up in my fonts folder as well. [...]

    "images": {
      "files": [
        "../bower_components/photoswipe/dist/default-skin/default-skin.svg",
        "images/**/*"
      ]
    }

[...]

JvanderHeide avatar May 07 '15 15:05 JvanderHeide

There also seems to be an issue with .gif types. i used this workaround but it was also and issue with the package set up itself. #27

escobar022 avatar May 16 '15 23:05 escobar022

Been thinking about this. Pretty sure I'm going to have it read the SVG real quick and determine if it's a font from the content of the SVG. I'll probably make a separate npm module to do this.

austinpray avatar Jun 14 '15 20:06 austinpray

@austinpray just recently used something like that to check for SVG fonts vs SVG images:

var _      = require('lodash');
var filter = require('gulp-filter');
var gulp   = require('gulp');

// Check for "<font id" string in given file
function isSVGFont(file) {
  return file.contents.toString().indexOf('<font id') > -1;
}

// Fonts
return gulp.src(fonts)
.pipe(filter(function(file){
  if(_.endsWith(file.path, '.svg')) {
    return isSVGFont(file);
  } else {
    return true;
  }
}))
.pipe( // Continue pipe...

// Images
return gulp.src(images)
.pipe(filter(function(file){
  if(_.endsWith(file.path, '.svg')) {
    return !isSVGFont(file); // <-- Inverting the returned boolean here
  } else {
    return true;
  }
}))
.pipe( // Continue pipe...

Despite that I'm not using asset-builder in this case (using NPM over Bower) I figured it might still be of interest to you.

JvanderHeide avatar Dec 17 '15 14:12 JvanderHeide

The lazyweb delivers! Thank you @JvanderHeide.

austinpray avatar Dec 17 '15 16:12 austinpray

Just ran into the same problem, I notice that types.json is also incomplete, no .svg (or .tiff, etc) in the images key, and the fonts seems a little broad. MIME type detection might have been more correct, but I'm not sure whether there are different mime types for SVG fonts/images (as they are one and the same).

leehambley avatar Dec 17 '15 17:12 leehambley