Brandon Durham
Brandon Durham

Reputation: 7707

Possible to load SVG files with Browserify

Trying to require an svg with the this line:

var framea = require('../images/frames/text-frame-one.svg');

… and getting this error when compiling:

events.js:85
      throw er; // Unhandled 'error' event
            ^
SyntaxError: Unexpected token

The SVG is incredibly simple and shouldn't be the cause of any errors. Is there a way to load an SVG reliably with Browserify?

Upvotes: 1

Views: 1105

Answers (1)

Brandon Durham
Brandon Durham

Reputation: 7707

I found svgify but had forgotten to add it to my package.json as a transform:

"browserify": {
  "transform": ["svgify"]
}

Upvotes: 2

Related Questions