Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Support css url functions without explicitly import #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

- [#2251](https://github.com/teambit/bit/issues/2251) support css url functions without explicitly import

## [2.1.5] - 2020-01-12

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ module.exports = function detective(fileContent, syntax) {
};

function isImportStatement(node) {
if (node.type === 'Atrule' && node.name === 'import') {
if ((node.type === 'Atrule' && node.name === 'import') || node.type === 'Url') {
return true;
}
return false;
}

function extractDependencies(importStatementNode) {
// handle URL functions without import, like `background-image: url('../button.png');`
if (importStatementNode.type === 'Url') {
return importStatementNode.value.value.replace(/["']/g, '');
}
// handle URL import @import url("baz.css");
if (
importStatementNode.prelude.type === 'AtrulePrelude' &&
Expand Down