image-webpack-loader icon indicating copy to clipboard operation
image-webpack-loader copied to clipboard

Deprecated file-loader

Open daviddavo opened this issue 4 years ago • 3 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/

daviddavo avatar Feb 15 '21 19:02 daviddavo

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

tcoopman avatar Feb 16 '21 09:02 tcoopman

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',
       },

sanbornhilland avatar Mar 10 '21 04:03 sanbornhilland

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.

daliborfilus avatar May 14 '22 17:05 daliborfilus