Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a callback to execute to modify the pre-processing pipeline at runtime for a web file #59

Closed
Shazwazza opened this Issue Dec 30, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@Shazwazza
Copy link
Owner

Shazwazza commented Dec 30, 2016

in Smidge 2.0 you can specify a callback in options to modify the default pipeline, for example:

services.AddSmidge(_config)
    .Configure<SmidgeOptions>(options =>
    {
        options.PipelineFactory.OnGetDefault = GetDefaultPipelineFactory;
    });

The GetDefaultPipeline method could do something like:

/// <summary>
/// A callback used to modify the default pipeline to use Nuglify for JS processing
/// </summary>
/// <param name="fileType"></param>
/// <param name="processors"></param>
/// <returns></returns>
private static PreProcessPipeline GetDefaultPipelineFactory(WebFileType fileType, IReadOnlyCollection<IPreProcessor> processors)
{
    switch (fileType)
    {
        case WebFileType.Js:
            return new PreProcessPipeline(new IPreProcessor[]
            {
                processors.OfType<NuglifyJs>().Single()
            });                
    }
    //returning null will fallback to the logic defined in the registered PreProcessPipelineFactory
    return null;
}

@Shazwazza Shazwazza added this to the 2.0 milestone Dec 30, 2016

@Shazwazza Shazwazza closed this Dec 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.