tcoopman / image-webpack-loader

Image loader module for webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecated file-loader

daviddavo opened this issue · comments

Now It's recommended to use asset modules instead of file-loader, url-loader, etc.

https://github.com/webpack-contrib/file-loader#file-loader
https://webpack.js.org/guides/asset-modules/

You're always welcome to create a PR. I don't have the time to look into this right now.

I'm not sure if any changes are necessary. The following change appears to work for me:

diff --git a/config/webpack.common.js b/config/webpack.common.js
index b582cd802..081418b4c 100644
--- a/config/webpack.common.js
+++ b/config/webpack.common.js
@@ -271,7 +271,6 @@ const config = {
 
         test: /\.(png|jpg|webp|)$/i,
         use: [
-          'file-loader',
           {
             loader: 'image-webpack-loader',
             options: {
@@ -279,6 +278,7 @@ const config = {
             },
           },
         ],
+        type: 'asset/resource',
       },

Or type: 'asset', to auto detect if the image should be inlined or not, or 'asset/inline' to always inline. See the Webpack Asset Modules docs.
This could be mentioned in the README though.