Parcel: tries to import datauri as a file if it is in quotes

Created on 6 Dec 2017  ·  8Comments  ·  Source: parcel-bundler/parcel

<!--index.html-->
<!doctype html>
<link rel="stylesheet" href="./lol.css">

works!:

/* lol.css */
body {
  background: url(data:image/gif;base64,something);
}

error:

/* lol.css */
body {
  background: url("data:image/gif;base64,something");
}

(🚨 /Users/chee/projects/nothing/lol.css:2:3: Cannot resolve dependency './data:image/gif;base64,something')

Most helpful comment

perhaps the whole cache should be invalidated when parcel updates

That was added in #67

All 8 comments

I'll work on this.

Fixed by #50.

Awaiting release of this fix :+1:

I tried using master since I couldn't wait and I am still encountering this issue:

/Users/nijikokun/ui.css:1:21599: Cannot resolve dependency './data:image/svg+xml;charset=utf-8,%3Csvg width='10' height='8' vie
>

The line in question is (notice the url inside, which appears to return true on the first check):

background:#e8e8e8 url("data:image/svg+xml;charset=utf-8,%3Csvg width='10' height='8' viewBox='3 7 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%2341474E' fill-rule='evenodd' d='M6.333 15L3 11.667l1.333-1.334 2 2L11.667 7 13 8.333z'/%3E%3C/svg%3E")

Here is me checking the contents of is-url.js to confirm that the code I am using has the changes which it does:

global/node_modules/parcel-bundler
▶ cat src/utils/is-url.js
const isURL = require('is-url');

// Matches anchor (ie: #raptors)
const ANCHOR_REGEXP = /^#/;

// Matches scheme (ie: tel:, mailto:, data:)
const SCHEME_REGEXP = /^[a-z]*\:/i;

module.exports = function (url) {
  return isURL(url) || ANCHOR_REGEXP.test(url) || SCHEME_REGEXP.test(url);
};

global/node_modules/parcel-bundler
▶

I have found the issue, there was a .cache directory that needs to be blown away first. It works as intended.

thank you, everyone.

perhaps the whole cache should be invalidated when parcel updates

perhaps the whole cache should be invalidated when parcel updates

That was added in #67

Was this page helpful?
0 / 5 - 0 ratings