Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differentiate between SVG images and fonts in webpack loader

I'm trying to create a Webpack loader, and all other file types are working; however, when it comes SVGs, the loader gets confused and empties the SVG image document via the font loader. Below is the code I am using...

  /* Images still being loaded in this test for some reason */
  {
    test   : /\.svg/,
    exclude: '../src/images',
    loader : 'file?prefix=font/'
  },
  {
    test   : /\.svg/,
    include: '../src/images',
    loader : 'file-loader'
  }

As you can see, I have tried using include/exclude in the tests, however, this hasn't worked.

Any ideas?

like image 571
Matt Maclennan Avatar asked Jul 26 '16 13:07

Matt Maclennan


1 Answers

To fix this, I just used RegEx to exclude any path containing images, like so...

 // FONT LOADER
 {
    test   : /\.svg/,
    exclude: [/images/],
    loader : 'file?prefix=font/'
 },
 // OTHER FILES LOADER
 {
    test: /\.(mp4|ogg|svg)$/,
    loader: 'file-loader'
 }
like image 168
Matt Maclennan Avatar answered Nov 14 '22 21:11

Matt Maclennan