danielstgt / laravel-mix-svg-vue

A Laravel Mix extension to inline SVG files with Vue.js and automatically optimize them with SVGO
MIT License
38 stars 9 forks source link

Error: You may need an appropriate loader to handle this file type #1

Closed marufmax closed 5 years ago

marufmax commented 5 years ago

I am getting this:

ERROR in ./node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <?xml version="1.0" standalone="no"?>
| <!--
| Font Awesome Free 5.10.2 by @fontawesome - https://fontawesome.com
 @ ./node_modules/@fortawesome/fontawesome-free/css/all.css (./node_modules/css-loader??ref--5-2!./node_modules/postcss-loader/src??postcss0!./node_modules/@fortawesome/fontawesome-free/css/all.css) 7:77864-77905
 @ ./node_modules/css-loader??ref--5-2!./node_modules/postcss-loader/src??postcss0!./node_modules/resolve-url-loader??ref--5-4!./node_modules/sass-loader/dist/cjs.js??ref--5-5!./resources/assets/sass/app.scss
 @ ./resources/assets/sass/app.scss

My webpack.mix.js is:

mix.js("resources/assets/js/app.js", "public/js/app.js").svgVue({
    svgPath: 'resources/svg',
    extract: false
});

What I understand is, Webpack can't load Svg file. Do I need any loader for resolving this error?

danielstgt commented 5 years ago

I was able to reproduce the error with the @fortawesome/fontawesome-free package by importing it in a css file. Specifically importing @fortawesome/fontawesome-free/css/all.css caused the same error.

What happened was that laravel-mix-svg-vue was overriding the .svg rule check for webpack, so no loader felt responsible...

A fix has been published, after upgrading to the latest version (0.2.3) you should be good to go.

Upgrading with yarn:

yarn upgrade laravel-mix-svg-vue

Or with npm:

npm update laravel-mix-svg-vue

Readding packages is also an option, this will install the latest available version.

Please reopen this issue if your problem isn't fixed.