Skip to content

Commit bb981e9

Browse files
committed
Replace file-loader with asset modules
It's been deprecated in favor of https://webpack.js.org/guides/asset-modules/
1 parent a2a3655 commit bb981e9

File tree

5 files changed

+14
-42
lines changed

5 files changed

+14
-42
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"cookie": "0.4.0",
3232
"core-js": "3.6.5",
3333
"detect-node": "2.0.3",
34-
"file-loader": "6.2.0",
3534
"filesize": "2.0.4",
3635
"generic-diff": "1.0.1",
3736
"he": "1.1.1",

root/flowstub.js.flow

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* @flow strict
33
* Bogus file for use in .flowconfig.
44
* Non-JavaScript files are mapped to here, so we can require() them
5-
* via Webpack's file-loader without Flow triggering import errors.
5+
* via Webpack's asset modules without Flow triggering import errors.
66
*/
77
export default ({}: mixed);

root/static/manifest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* This module is used to look up assets in webpack's manifest, which maps
1111
* asset names to their public URLs (which include a hash in the filename
1212
* in production). This is really only useful for looking up JavaScript
13-
* bundles; for other types of assets, we use webpack's file-loader. This
13+
* bundles; for other types of assets, we use webpack's asset modules. This
1414
* module shouldn't be used in any client scripts, as it makes no sense
1515
* there. The actual manifest file (./build/rev-manifest) doesn't exist
1616
* until after the client scripts are bundled.

webpack/moduleConfig.js

+12-22
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,22 @@ module.exports = {
3535
},
3636
{
3737
test: /\.(png|svg|jpg|gif)$/,
38-
use: [
39-
{
40-
loader: 'file-loader',
41-
options: {
42-
name: (
43-
PRODUCTION_MODE
44-
? '[name]-[hash:7].[ext]'
45-
: '[name].[ext]'
46-
),
47-
},
48-
},
49-
],
38+
type: 'asset/resource',
39+
generator: {
40+
filename: PRODUCTION_MODE
41+
? '[name]-[hash:7][ext]'
42+
: '[name][ext]',
43+
},
5044
},
5145
{
5246
test: /\.less$/,
47+
type: 'asset/resource',
48+
generator: {
49+
filename: PRODUCTION_MODE
50+
? '[name]-[hash:7].css'
51+
: '[name].css',
52+
},
5353
use: [
54-
{
55-
loader: 'file-loader',
56-
options: {
57-
name: (
58-
PRODUCTION_MODE
59-
? '[name]-[hash:7].css'
60-
: '[name].css'
61-
),
62-
},
63-
},
6454
{
6555
loader: 'less-loader',
6656
options: {lessOptions},

yarn.lock

-17
Original file line numberDiff line numberDiff line change
@@ -2856,14 +2856,6 @@ file-entry-cache@^5.0.1:
28562856
dependencies:
28572857
flat-cache "^2.0.1"
28582858

2859-
2860-
version "6.2.0"
2861-
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d"
2862-
integrity sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw==
2863-
dependencies:
2864-
loader-utils "^2.0.0"
2865-
schema-utils "^3.0.0"
2866-
28672859
28682860
version "2.0.2"
28692861
resolved "https://registry.yarnpkg.com/file-url/-/file-url-2.0.2.tgz#e951784d79095127d3713029ab063f40818ca2ae"
@@ -3801,15 +3793,6 @@ loader-utils@^1.4.0:
38013793
emojis-list "^3.0.0"
38023794
json5 "^1.0.1"
38033795

3804-
loader-utils@^2.0.0:
3805-
version "2.0.0"
3806-
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0"
3807-
integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==
3808-
dependencies:
3809-
big.js "^5.2.2"
3810-
emojis-list "^3.0.0"
3811-
json5 "^2.1.2"
3812-
38133796
locate-path@^2.0.0:
38143797
version "2.0.0"
38153798
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"

0 commit comments

Comments
 (0)