Skip to content

CSS optimizer makes url() relative to cssIn option #350

@cmbuckley

Description

@cmbuckley

Per the documentation at http://requirejs.org/docs/optimization.html#onecss:

The url() path fixing will always fix the paths relative to the cssIn build option path, not the out build option.

This causes a problem when optimizing a single CSS file where the out path is not in the same directory as the cssIn path. I see a few options but haven't had a chance to think about the pros and cons of each properly:

  • Determine the correct path by using the out option. Intuitive to configure but might be difficult to calculate in practise and doesn't allow for a custom override.
  • Prepend baseUrl to relative url() paths. Might cause problems when optimizing a whole project, as the baseUrl would be being used for 2 different things.
  • Prepend a new option cssPrefix (or cssBaseUrl etc.) to relative url() paths. This seems the simplest choice but adds another config parameter.

At first glance, the third option seems best, but it might be desirable to try the first option if no config option is passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions