Skip to content

ReactConfig lack of wildcard subdirectory search for adding components #526

@tokyo0709

Description

@tokyo0709

Adding all of our components to be able to render them server side would eventually get out of hand. There should be a way to wildcard and search subdirectories.

Example of the problem

public static class ReactConfig
{
    public static void Configure()
    {
        ReactSiteConfiguration.Configuration
            .AddScript("~/ClientApp/Components/Comments/Comment.jsx")
            .AddScript("~/ClientApp/Components/Comments/CommentBox.jsx")
            .AddScript("~/ClientApp/Components/Comments/CommentForm.jsx")
            .AddScript("~/ClientApp/Components/Comments/CommentList.jsx");
            // Additional component folders with endless amounts of component jsx files
    }
}

However this seems to be done effectively with the BabelBundle package that implements IncludeDirectory in this example. If this format could be mimicked in ReactSiteConfiguration.Configuration it should solve the issue.

Proposed Solution

public static class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        // Searches components folder for all jsx files and all subdirectories for jsx files
        bundles.Add(new BabelBundle("~/scripts/components")
            .IncludeDirectory("~/ClientApp/Components", "*.jsx", true));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions