Skip to content

Commit

Permalink
regression fix some less/scss compilation sourcemap issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Dec 20, 2017
1 parent 1590f6d commit 948daac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
5 changes: 2 additions & 3 deletions external/scssphp/src/SourceMap/SourceMapGenerator.php
Expand Up @@ -172,18 +172,17 @@ public function generateJson()
// An optional source root, useful for relocating source files on a server or removing repeated values in the
// 'sources' entry. This value is prepended to the individual entries in the 'source' field.
$root = $this->options['sourceRoot'];

if ($root) {
// $sourceMap['sourceRoot'] = $root;
$sourceMap['sourceRoot'] = $root;
// A list of symbol names used by the 'mappings' entry.
$sourceMap['names'] = array();
}

// A list of original sources used by the 'mappings' entry.
$sourceMap['sources'] = array();
foreach($this->sources as $source_uri => $source_filename) {
$sourceMap['sources'][] = $this->normalizeFilename($source_filename);
}
$sourceMap['names'] = array();

// A string with the encoded mapping data.
$sourceMap['mappings'] = $mappings;
Expand Down
27 changes: 3 additions & 24 deletions framework/core/subsystems/expCSS.php
Expand Up @@ -453,11 +453,6 @@ public static function auto_compile_less($less_pname, $css_fname, $vars=array())
} else {
$map_write_to = BASE . 'tmp/css/' . $less_cname . ".map";
}
if (PATH_RELATIVE === '/') {
$mapbasepath = "";
} else {
$mapbasepath = rtrim(str_replace(PATH_RELATIVE, '', BASE), '/');
}
$iless_options = array(
'sourceMap' => true, // output .map file?
'sourceMapOptions' => array(
Expand All @@ -471,7 +466,7 @@ public static function auto_compile_less($less_pname, $css_fname, $vars=array())
// output source contents?
'source_contents' => false,
// base path for filename normalization
'base_path' => $mapbasepath, // base (difference between) file & url locations, removed from ALL source files in .map
'base_path' => rtrim(str_replace(PATH_RELATIVE, '', BASE), '/'), // base (difference between) file & url locations, removed from ALL source files in .map
),
);
}
Expand Down Expand Up @@ -584,21 +579,13 @@ public static function auto_compile_less($less_pname, $css_fname, $vars=array())
$map_url = PATH_RELATIVE . 'tmp/css/' . $less_cname . ".map";
$map_filename = PATH_RELATIVE . $css_fname;
}
if (PATH_RELATIVE === '/') {
$mapbasepath = "";
} else {
$mapbasepath = rtrim(str_replace(PATH_RELATIVE, '', BASE), '/');
}
$less->setOptions(array(
// 'outputSourceFiles' => true, // include css source in .map file?
'sourceMap' => true, // output .map file?
'sourceMapWriteTo' => $map_write_to,
'sourceMapURL' => $map_url,
// 'sourceMapWriteTo' => dirname(BASE . $less_pname) . '/' . $less_cname . ".map", // file location of .map file
// 'sourceMapURL' => dirname(PATH_RELATIVE . $less_pname) . '/' . $less_cname . ".map", // url location of .map file
'sourceMapFilename' => $map_filename, // url location of .css file
'sourceMapBasepath' => $mapbasepath, // base (difference between) file & url locations, removed from ALL source files in .map
// 'sourceRoot' => str_replace(PATH_RELATIVE, '', BASE),
'sourceMapBasepath' => rtrim(realpath(str_replace(PATH_RELATIVE, '', BASE)), '/'), // base (difference between) file & url locations, removed from ALL source files in .map
'sourceRoot' => '/',
// 'sourceMapRootpath' => PATH_RELATIVE . $less_pname, // tacked onto ALL source files in .map
));
Expand Down Expand Up @@ -704,21 +691,13 @@ public static function auto_compile_scss($scss_pname, $css_fname, $vars=array())
}

if (DEVELOPMENT && LESS_COMPILER_MAP && $scss_compiler == 'scssphp') {
if (PATH_RELATIVE === '/') {
$mapbasepath = "";
} else {
$mapbasepath = rtrim(str_replace(PATH_RELATIVE, '', BASE), '/');
}
$scss->setSourceMap((int)LESS_COMPILER_MAP); // output .map file?
$scss->setSourceMapOptions(array(
// 'outputSourceFiles' => true, // include css source in .map file?
'sourceMapWriteTo' => BASE . 'tmp/css/' . $scss_cname . ".map",
'sourceMapURL' => PATH_RELATIVE . 'tmp/css/' . $scss_cname . ".map",
// 'sourceMapWriteTo' => dirname(BASE . $scss_pname) . '/' . $scss_cname . ".map", // file location of .map file
// 'sourceMapURL' => dirname(PATH_RELATIVE . $scss_pname) . '/' . $scss_cname . ".map", // url location of .map file
'sourceMapFilename' => PATH_RELATIVE . $css_fname, // url location of .css file
'sourceMapBasepath' => $mapbasepath, // base (difference between) file & url locations, removed from ALL source files in .map
// 'sourceRoot' => str_replace(PATH_RELATIVE, '', BASE),
'sourceMapBasepath' => rtrim((str_replace(PATH_RELATIVE, '', BASE)), '/'), // base (difference between) file & url locations, removed from ALL source files in .map
'sourceRoot' => '/',
// 'sourceMapRootpath' => PATH_RELATIVE . $scss_pname, // tacked onto ALL source files in .map
));
Expand Down

0 comments on commit 948daac

Please sign in to comment.