Skip to content

Commit 01f6ec0

Browse files
author
Andrey Fedoseev
committed
Use "sourceRoot" attribute in LESS source maps to handle relative paths to source files
1 parent dc7f9da commit 01f6ec0

File tree

1 file changed

+2
-4
lines changed
  • static_precompiler/compilers

1 file changed

+2
-4
lines changed

static_precompiler/compilers/less.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ def compile_file(self, source_path):
6767

6868
# LESS, unlike SASS, can't add correct relative paths in source map when the compiled file
6969
# is not in the same dir as the source file. We fix it here.
70-
sourcemap["sources"] = [
71-
"../" * len(source_path.split("/")) + posixpath.dirname(source_path) + "/" + source
72-
for source in sourcemap["sources"]
73-
]
70+
sourcemap["sourceRoot"] = "../" * len(source_path.split("/")) + posixpath.dirname(source_path)
71+
7472
sourcemap["file"] = posixpath.basename(source_path)
7573

7674
with open(sourcemap_full_path, "w") as sourcemap_file:

0 commit comments

Comments
 (0)