From 42e636a3d1abeb70454be372d51129fc4497f5e8 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 22 Sep 2021 15:36:26 +0200 Subject: [PATCH] Webpack: use new asset module instead of deprecated file-loader --- package.json | 1 - webpack.config.js | 22 +++++++++++++--------- yarn.lock | 17 ----------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index fd705bc..a669f68 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "electron": "^15.0.0", "electron-builder": "^22.11.5", "eslint": "^7.10.0", - "file-loader": "^6.0.0", "image-minimizer-webpack-plugin": "^2.2.0", "imagemin-gifsicle": "^7.0.0", "imagemin-mozjpeg": "^9.0.0", diff --git a/webpack.config.js b/webpack.config.js index 3f25d9c..bee15dd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -46,14 +46,17 @@ const config = { }, { test: /\.(woff2?|eot|ttf|otf)$/i, - use: 'file-loader?name=../fonts/[name].[ext]', + type: 'asset/resource', + generator: { + filename: '../fonts/[name][ext]', + }, }, { test: /\.(png|jpe?g|gif|svg)$/i, - use: [ - 'file-loader?name=../images/[name].[ext]', - ], - type: 'asset', + type: 'asset/resource', + generator: { + filename: '../images/[name][ext]', + }, }, { test: /\.ts$/i, @@ -63,13 +66,14 @@ const config = { configFile: 'tsconfig.frontend.json', } }, - exclude: '/node_modules/' + exclude: '/node_modules/', }, { test: /\.html$/i, - use: [ - 'file-loader?name=../[name].[ext]', - ] + type: 'asset/resource', + generator: { + filename: '../[name][ext]', + }, } ], }, diff --git a/yarn.lock b/yarn.lock index 442e98c..04a726e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2956,14 +2956,6 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" -file-loader@^6.0.0: - version "6.2.0" - resolved "https://registry.npmjs.org/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d" - integrity sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw== - dependencies: - loader-utils "^2.0.0" - schema-utils "^3.0.0" - file-type@5.2.0, file-type@^5.2.0: version "5.2.0" resolved "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" @@ -4015,15 +4007,6 @@ loader-utils@^1.4.0: emojis-list "^3.0.0" json5 "^1.0.1" -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"