webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 255 forks source link

Problem with import webp image #381

Closed undermuz closed 3 years ago

undermuz commented 3 years ago

Expected Behavior

Same behavior as for other images, for example: png, jpg

Actual Behavior

ERROR in ./src/img/example-image.webp 1:5 Module parse failed: Unexpected token (1:5) 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 (Source code omitted for this binary file)

Code

{
                test: /\.(png|jpg|gif|svg|webp)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            outputPath: commonPaths.imagesFolder,
                        },
                    },
                ]
}
import Example from 'img/example-image.webp'

How Do We Reproduce?

Add "webp" to test section in file-loader config and import any webp image like: "import Example from 'your-webp-image.wepb'"

alexander-akait commented 3 years ago

Something wrong with your configuration, not related to file-loader, reproducible steps works fine