Skip to content

Multiple instances with generateScopedName #37

@MarcusLongmuir

Description

@MarcusLongmuir

Creating multiple instances of this plugin that specify distinct generateScopedName functions causes unexpected behaviour as the provided function is effectively set as global.

This causes the last instantiated plugin's generateScopedName function to be used for all instances of the plugin, which in my case is very difficult to work around.

const pluginOne = postcssModules({
  generateScopedName: function(nodeName, fileName, css) {
    return "one";
  },
});

const pluginTwo = postcssModules({
  generateScopedName: function(nodeName, fileName, css) {
    return "two";
  },
});

//Using pluginOne now will result in all classes being named "two"

Expected behaviour would be for the provided function to be used for only the instance of plugin that is constructed with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions