From f81b4e6782da14fe9a2411e1552c2612d42eea8a Mon Sep 17 00:00:00 2001 From: David First Date: Fri, 24 Jan 2020 16:51:02 -0500 Subject: [PATCH] resolve teambit/bit/issues/2251, support css url functions without explicitly import --- CHANGELOG.md | 2 ++ .../detectives/detective-css-and-preprocessors/index.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b3cd6..6f11fb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/dependency-builder/detectives/detective-css-and-preprocessors/index.ts b/src/dependency-builder/detectives/detective-css-and-preprocessors/index.ts index 9b163c0..860ee46 100644 --- a/src/dependency-builder/detectives/detective-css-and-preprocessors/index.ts +++ b/src/dependency-builder/detectives/detective-css-and-preprocessors/index.ts @@ -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' &&