Skip to content

Commit 1f0c8e9

Browse files
committed
fix: work around url-loader 1.1.0 regression
close #2242
1 parent 7e1862f commit 1f0c8e9

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

packages/@vue/cli-service/lib/config/base.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ module.exports = (api, options) => {
1212
)
1313
}
1414

15+
const genUrlLoaderOptions = dir => {
16+
return {
17+
limit: inlineLimit,
18+
// use explicit fallback to avoid regression in url-loader>=1.1.0
19+
fallback: {
20+
loader: 'file-loader',
21+
options: {
22+
name: genAssetSubPath(dir)
23+
}
24+
}
25+
}
26+
}
27+
1528
webpackConfig
1629
.mode('development')
1730
.context(api.service.context)
@@ -87,10 +100,7 @@ module.exports = (api, options) => {
87100
.test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
88101
.use('url-loader')
89102
.loader('url-loader')
90-
.options({
91-
limit: inlineLimit,
92-
name: genAssetSubPath('img')
93-
})
103+
.options(genUrlLoaderOptions('img'))
94104

95105
// do not base64-inline SVGs.
96106
// https://github.com/facebookincubator/create-react-app/pull/1180
@@ -108,20 +118,14 @@ module.exports = (api, options) => {
108118
.test(/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/)
109119
.use('url-loader')
110120
.loader('url-loader')
111-
.options({
112-
limit: inlineLimit,
113-
name: genAssetSubPath('media')
114-
})
121+
.options(genUrlLoaderOptions('media'))
115122

116123
webpackConfig.module
117124
.rule('fonts')
118125
.test(/\.(woff2?|eot|ttf|otf)(\?.*)?$/i)
119126
.use('url-loader')
120127
.loader('url-loader')
121-
.options({
122-
limit: inlineLimit,
123-
name: genAssetSubPath('fonts')
124-
})
128+
.options(genUrlLoaderOptions('fonts'))
125129

126130
// Other common pre-processors ---------------------------------------------
127131

packages/@vue/cli-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"string.prototype.padend": "^3.0.0",
6363
"thread-loader": "^1.1.5",
6464
"uglifyjs-webpack-plugin": "^1.2.7",
65-
"url-loader": "^1.0.1",
65+
"url-loader": "^1.1.0",
6666
"vue-loader": "^15.3.0",
6767
"webpack": "^4.15.1",
6868
"webpack-bundle-analyzer": "^2.13.1",

yarn.lock

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,10 @@ agentkeepalive@^2.2.0:
13101310
version "2.2.0"
13111311
resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef"
13121312

1313+
ajv-errors@^1.0.0:
1314+
version "1.0.0"
1315+
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59"
1316+
13131317
ajv-keywords@^2.1.0:
13141318
version "2.1.1"
13151319
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
@@ -10844,7 +10848,15 @@ sax@^1.2.4, sax@~1.2.1, sax@~1.2.4:
1084410848
version "1.2.4"
1084510849
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
1084610850

10847-
schema-utils@^0.4.0, schema-utils@^0.4.2, schema-utils@^0.4.3, schema-utils@^0.4.4, schema-utils@^0.4.5:
10851+
schema-utils@1.0.0:
10852+
version "1.0.0"
10853+
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770"
10854+
dependencies:
10855+
ajv "^6.1.0"
10856+
ajv-errors "^1.0.0"
10857+
ajv-keywords "^3.1.0"
10858+
10859+
schema-utils@^0.4.0, schema-utils@^0.4.2, schema-utils@^0.4.4, schema-utils@^0.4.5:
1084810860
version "0.4.5"
1084910861
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.5.tgz#21836f0608aac17b78f9e3e24daff14a5ca13a3e"
1085010862
dependencies:
@@ -12265,13 +12277,13 @@ url-join@^4.0.0:
1226512277
version "4.0.0"
1226612278
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.0.tgz#4d3340e807d3773bda9991f8305acdcc2a665d2a"
1226712279

12268-
url-loader@^1.0.1:
12269-
version "1.0.1"
12270-
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-1.0.1.tgz#61bc53f1f184d7343da2728a1289ef8722ea45ee"
12280+
url-loader@^1.0.1, url-loader@^1.1.0:
12281+
version "1.1.0"
12282+
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-1.1.0.tgz#64dd296626d935c68d72ed9d9c69cf3c6ff933ac"
1227112283
dependencies:
1227212284
loader-utils "^1.1.0"
1227312285
mime "^2.0.3"
12274-
schema-utils "^0.4.3"
12286+
schema-utils "1.0.0"
1227512287

1227612288
url-parse-lax@^1.0.0:
1227712289
version "1.0.0"

0 commit comments

Comments
 (0)