Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Asynchronously set options #56

Open
garygreen opened this issue Jan 21, 2020 · 0 comments
Open

Asynchronously set options #56

garygreen opened this issue Jan 21, 2020 · 0 comments

Comments

@garygreen
Copy link

Currently you can only supply options to the plugin with an object. It would be useful if you could also pass a function and call the given setPurgeCssOptions callback to set the options.

require('@fullhuman/postcss-purgecss')(function(setPurgeCssOptions) {
    exec_command('git ls-files js/*.js', function(gitFiles) {
        setPurgeCssOptions({
            content: toArray(gitFiles),
        });
    });
});

Use case

Our particular use case is we want to build up a list of content files for PurgeCSS to consider but only if it's part of git/version control - as we are calling an async process we need to build the options up asynchronously. It's possible we could do this by creating our own plugin and then hooking into that, but I just thought I'd make this suggestion as it would provide an easier API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant