Skip to content

Expose current filename to visitors #1254

@Knagis

Description

@Knagis

#1170 added the ability for visitors to add dependencies, however, for the visitors to be able to do anything with such dependencies, it would be very useful if the current filename would be exposed as well.

This would allow a visitor to process a relative path specified in the CSS content.

I am currently trying to implement something like @value (https://github.com/css-modules/css-modules/blob/master/docs/values-variables.md) with visitor, but lack of the filename means i can't really implement @value name from "./foo.css" syntax.

Proposal: add sources property, same value as passed to StyleSheet() visitor (which i could use but don't want to as it needlessly serializes the whole AST..)

export interface VisitorOptions {
  readonly sources: readonly string[];
  addDependency: (dep: VisitorDependency) => void;
}

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions