mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Preserve line numbers when compiling SCSS with sourcemap
This commit is contained in:
parent
9d4961ff0d
commit
770cde8b8a
2 changed files with 10 additions and 5 deletions
|
|
@ -228,10 +228,10 @@ class Formatter
|
|||
{
|
||||
// Get the cleaned and concatenated content.
|
||||
$imported_list = [];
|
||||
$content = self::concatCSS($source_filename, $target_filename, true, $imported_list);
|
||||
$content = self::concatCSS($source_filename, $target_filename, false, $imported_list);
|
||||
if (strpos($content, '@charset') === false)
|
||||
{
|
||||
$content = '@charset "UTF-8";' . "\n" . $content;
|
||||
$content = '@charset "UTF-8"; ' . $content;
|
||||
}
|
||||
$primary_filename = is_array($source_filename) ? array_first($source_filename) : $source_filename;
|
||||
$sourcemap_filename = preg_replace('/\.css$/', '.map', $target_filename);
|
||||
|
|
@ -361,6 +361,7 @@ class Formatter
|
|||
{
|
||||
$charsets = [];
|
||||
$imported_urls = [];
|
||||
$import_type = 'normal';
|
||||
$result = '';
|
||||
|
||||
if (!is_array($source_filename))
|
||||
|
|
@ -450,6 +451,11 @@ class Formatter
|
|||
trigger_error('Imported file not found: ' . $error_filename, \E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
if ($import_type === 'scss')
|
||||
{
|
||||
$import_content = preg_replace('!//.*?\n!s', '', $import_content);
|
||||
$import_content = preg_replace('![\r\n]+!', ' ', $import_content);
|
||||
}
|
||||
return trim($import_content);
|
||||
}, $content);
|
||||
|
||||
|
|
@ -506,7 +512,8 @@ class Formatter
|
|||
if (count($charsets))
|
||||
{
|
||||
$charset = '@charset "' . escape_dqstr(array_first($charsets)) . '";';
|
||||
$result = $charset . "\n" . $result;
|
||||
$delimiter = $import_type === 'scss' ? ' ' : "\n";
|
||||
$result = $charset . $delimiter . $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
@charset "UTF-8";
|
||||
@import url("//fonts.googleapis.com/css?family=Raleway:700,400");
|
||||
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap");
|
||||
/* Original file: tests/_data/formatter/scss.source1.scss */
|
||||
/* Original file: tests/_data/formatter/scss.source2.scss */
|
||||
.inc1 {
|
||||
margin: 5px;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue