Skip to content

How To : Organizing javascript in a asp.net core modularized application (modules in dlls) #106

@mkgn

Description

@mkgn

My Application is organized in a way that some features are working as a plugin. Each plugin has it's own APIs, Views, Static files etc.. I am using ViewLocationExpander to find the view files owned by plugins which is not in the standard location but in the plugins relative path. Example;

[Starting MVC Application]
|__MainLayOut
|__Modules
    |__Plugin1
        |_Binaries
        |_Views (has shared, _viewimports etc.. local to this module)
        |_wwwroot (has static files local to this module)
    |
    |__Plugin2
        |_Binaries
        |_Views (has shared, _viewimports etc.. local to this module)
        |_wwwroot (has static files local to this module)

As you see in above structure if you delete the a plugin from the Modules folder entire plugin related features will get deactivated. So code for that plugin is 100% within the plugin directory.

Now I am planning to use RequireJS and try to modularize javascripts that is needed by each plugin. However the doucment says:

The requirejs entrypoint for each page will be loaded from ~/Scripts/Controllers/{area}/{controller}/{action}

But in my case RequireJS should be able to load the JS file not from the primary ~/Scripts folder but the /wwwroot/js folder which is inside the Plugin folder (\Modules\Plugin1\wwwroot\js). If I can get this done (May be like ViewLocationExpander), I can have a 100% modularized app.

Is this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions