Skip to content

Commit

Permalink
fix: don't break loader on invalid or not exists url or import token (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 30, 2018
1 parent 255c0f0 commit 9e52d26
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
14 changes: 12 additions & 2 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ module.exports = function loader(content, map) {
// Prepare replacer to change from `___CSS_LOADER_IMPORT___INDEX___` to `require('./file.css').locals`
const importItemReplacer = (item) => {
const match = placholderRegExps.importItem.exec(item);
const idx = +match[1];
const idx = Number(match[1]);

if (!importItems[idx]) {
return item;
}

const importItem = importItems[idx];
const importUrl = importUrlPrefix + importItem.url;

Expand Down Expand Up @@ -208,7 +213,12 @@ module.exports = function loader(content, map) {
placholderRegExps.urlItemG,
(item) => {
const match = placholderRegExps.urlItem.exec(item);
let idx = +match[1];
let idx = Number(match[1]);

if (!urlItems[idx]) {
return item;
}

const urlItem = urlItems[idx];
const { url } = urlItem;

Expand Down
Loading

0 comments on commit 9e52d26

Please sign in to comment.