fix: Sourcemaps

- Les maps inline sont déjà dans le CSS généré
- Il faut enlever le chemin racine du SPIP

Note: ça ne fonctionne pas dès lors que le plugin scssphp est déposé
en lien symbolique, pour des histoires de `realpath` utilisé dans la lib
scssphp aussi.
pull/15/head
Matthieu Marcillaud 8 months ago
parent a8992afd56
commit 628380f238

@ -120,7 +120,7 @@ function scssphp_inline_compile($style, $contexte, $cache_options, $import_dirs,
// https://scssphp.github.io/scssphp/docs/#source-maps
if (defined('_SCSS_SOURCE_MAP') && constant('_SCSS_SOURCE_MAP') === true) {
$scss->setSourceMap(ScssPhp\ScssPhp\Compiler::SOURCE_MAP_INLINE);
$scss->setSourceMapOptions(array(
$scss->setSourceMapOptions([
// This value is prepended to the individual entries in the 'source' field.
'sourceRoot' => '',
// an optional name of the generated code that this source map is associated with.
@ -135,15 +135,15 @@ function scssphp_inline_compile($style, $contexte, $cache_options, $import_dirs,
'sourceMapRootpath' => '/',
// base path for filename normalization
// difference between file & url locations, removed from ALL source files in .map
'sourceMapBasepath' => '/local/cache-scss/'
));
'sourceMapBasepath' => _ROOT_CWD
]);
}
$files = [];
try {
$result = $scss->compileString($style, $contexte['file'] ?? null);
$out = (string) $result->getSourceMap() . $result->getCss();
$out = $result->getCss();
$files = $result->getIncludedFiles();
spip_log($log_pre. ' compile '. ($contexte['file'] ?? substr($style,0,100)) . ' :: '.spip_timer('scss_compile'), 'scssphp');

@ -32,7 +32,7 @@ function scss_cache_dir() {
function scss_compile($style, $contexte = array(), $throw = false) {
include_spip('inc/scssphp_compiler');
$import_dirs = array_filter(array_map('realpath', _chemin()));
$import_dirs = array_map(function($c) { return _ROOT_CWD . $c; }, _chemin());
$cache_options = array(
'cacheDir' => scss_cache_dir(),

Loading…
Cancel
Save