Skip to content

Commit 92bf251

Browse files
committed
Improve assets warning, remove unnecessary pattern matching in option
1 parent b9b56e4 commit 92bf251

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,11 @@ var OfflinePlugin = (function () {
306306
var index = assets.indexOf(cacheKey);
307307

308308
externalsCheck: if (index === -1) {
309-
if (_this3.externals.some(function (glob) {
310-
if ((0, _minimatch2['default'])(cacheKey, glob)) {
311-
return true;
312-
}
313-
})) {
309+
if (_this3.externals.length && _this3.externals.indexOf(cacheKey) !== -1) {
314310
break externalsCheck;
315311
}
316312

317-
compilation.warnings.push(new Error('OfflinePlugin: Cache asset [' + cacheKey + '] is not found in output assets'));
313+
compilation.warnings.push(new Error('OfflinePlugin: Cache asset [' + cacheKey + '] is not found in output assets,' + 'if it\'s an external asset, put it to |externals| option to remove this warning'));
318314
} else {
319315
assets.splice(index, 1);
320316
}

src/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,15 @@ export default class OfflinePlugin {
318318
const index = assets.indexOf(cacheKey);
319319

320320
externalsCheck: if (index === -1) {
321-
if (this.externals.some((glob) => {
322-
if (minimatch(cacheKey, glob)) {
323-
return true;
324-
}
325-
})) {
321+
if (this.externals.length && this.externals.indexOf(cacheKey) !== -1) {
326322
break externalsCheck;
327323
}
328324

329325
compilation.warnings.push(
330-
new Error(`OfflinePlugin: Cache asset [${ cacheKey }] is not found in output assets`)
326+
new Error(
327+
`OfflinePlugin: Cache asset [${ cacheKey }] is not found in output assets,` +
328+
`if it's an external asset, put it to |externals| option to remove this warning`
329+
)
331330
);
332331
} else {
333332
assets.splice(index, 1);

0 commit comments

Comments
 (0)