Skip to content

Map file incomplete source URL #128

@realjjaveweb

Description

@realjjaveweb

Not sure if there is still someone supporting this project, however I've noticed latest wp.org version generates map file with sources defined relatively to main domain, so if wordpress is in subdirectory (like domain.tld/blog/) this will be generated in example.css.map
"sources":["wp-content\/themes\/sometheme\/scss\/example.scss"]
which browser (at least Chrome) will translate to
domain.tld/wp-content/themes/sometheme/scss/example.scss
<= notice the missing /blog/ part

Note: this may or may not be related to issue #105

FIX:

In class/class-wp-scss.php when calling setSourceMapOptions() sourceRoot should reffer to home URL

$scssc->setSourceMapOptions(array(
  'sourceMapWriteTo' => $instance->css_dir . $map, // absolute path to a file to write the map to
  'sourceMapURL' => $map, // url of the map
  'sourceMapBasepath' => rtrim(ABSPATH, '/'), // base path for filename normalization
  
  // FIX: this was previously just '/'
  'sourceRoot' => home_url('/'), // This value is prepended to the individual entries in the 'source' field.
));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions