Skip to content

Commit 3db9a2b

Browse files
snitin315alexander-akait
authored andcommitted
refactor: remove file-loader and url-loader deps (#4951)
1 parent ea9da8c commit 3db9a2b

File tree

8 files changed

+49
-323
lines changed

8 files changed

+49
-323
lines changed

examples/default/webpack.config.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
"use strict";
22

3-
const { version } = require("webpack");
43
// our setup function adds behind-the-scenes bits to the config that all of our
54
// examples need
65
const { setup } = require("../util");
76

8-
let moduleRuleForPNG = {};
9-
10-
if (version.startsWith("5")) {
11-
moduleRuleForPNG = {
12-
test: /\.png$/,
13-
type: "asset/resource",
14-
generator: {
15-
filename: "images/[hash][ext][query]",
16-
},
17-
};
18-
} else {
19-
moduleRuleForPNG = {
20-
test: /\.png$/,
21-
loader: "file-loader",
22-
options: { prefix: "img/" },
23-
};
24-
}
7+
const moduleRuleForPNG = {
8+
test: /\.png$/,
9+
type: "asset/resource",
10+
generator: {
11+
filename: "images/[hash][ext][query]",
12+
},
13+
};
2514

2615
module.exports = setup({
2716
context: __dirname,

examples/general/config-array/webpack.config.js

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
"use strict";
22

3-
const { version } = require("webpack");
43
// our setup function adds behind-the-scenes bits to the config that all of our
54
// examples need
65
const { setup } = require("../../util");
76

8-
const isWebpack5 = version.startsWith("5");
9-
10-
let moduleRuleForPNG = {};
11-
12-
if (isWebpack5) {
13-
moduleRuleForPNG = {
14-
test: /\.png$/,
15-
type: "asset/resource",
16-
generator: {
17-
filename: "images/[hash][ext][query]",
18-
},
19-
};
20-
} else {
21-
moduleRuleForPNG = {
22-
test: /\.png$/,
23-
loader: "file-loader",
24-
options: { prefix: "img/" },
25-
};
26-
}
7+
const moduleRuleForPNG = {
8+
test: /\.png$/,
9+
type: "asset/resource",
10+
generator: {
11+
filename: "images/[hash][ext][query]",
12+
},
13+
};
2714

2815
module.exports = [
2916
setup({
@@ -53,19 +40,13 @@ module.exports = [
5340
test: /\.less$/,
5441
use: ["style-loader", "css-loader", "less-loader"],
5542
},
56-
isWebpack5
57-
? {
58-
test: /\.png$/,
59-
type: "asset/resource",
60-
generator: {
61-
filename: "images/[hash][ext][query]",
62-
},
63-
}
64-
: {
65-
test: /\.png$/,
66-
loader: "url-loader",
67-
options: { limit: 100000 },
68-
},
43+
{
44+
test: /\.png$/,
45+
type: "asset/resource",
46+
generator: {
47+
filename: "images/[hash][ext][query]",
48+
},
49+
},
6950
],
7051
},
7152
optimization: {

package-lock.json

Lines changed: 0 additions & 187 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"eslint-config-webpack": "^1.2.5",
104104
"eslint-plugin-import": "^2.23.2",
105105
"execa": "^5.1.1",
106-
"file-loader": "^6.2.0",
107106
"html-webpack-plugin": "^5.5.3",
108107
"http-proxy": "^1.18.1",
109108
"jest": "^29.5.0",
@@ -127,7 +126,6 @@
127126
"supertest": "^6.1.3",
128127
"tcp-port-used": "^1.0.2",
129128
"typescript": "^4.9.3",
130-
"url-loader": "^4.1.1",
131129
"wait-for-expect": "^3.0.2",
132130
"webpack": "^5.88.1",
133131
"webpack-cli": "^5.0.1",

0 commit comments

Comments
 (0)