cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] module.export= in generated SVG file

xstable opened this issue · comments

With jpeg next-optimized-images work very good, but for SVG it doesn't work at all.

I got some data in the image, but it looks like this (I've shorten the svg-sourcecode to give better overview):

<img style="max-width:100%" src="module.exports = &quot;data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0i......SHORTEN THE SVG HERE ...YzeiIvPgo8L3N2Zz4K&quot;" height="50" width="150" class="logo" alt="Logo">

The above img tag was generated with ?include, but it's the same with an external SVG file.

Why this happen?

Got it, was an missconfiguration of webpack:

webpack (config) {
    config.module.rules.push(
      {
        test: /\.(png|jpg|gif|eot|ttf|woff|woff2)$/,
        use: {
          loader: 'url-loader',
          options: {
            limit: 100000,
            esModule: false,
            name: '[name].[ext]',
          },
        },
      },

There in test I had SVG, which caused the issue