const mixinafDuvet::RequireJsConfigTweaks

afDuvet::RequireJsConfigTweaks

(Service) - Contribute functions to make last minute tweaks to the RequireJs config. After the tweaks are applied, the config is serialised as JSON and added to the page.

Example, to define multiple modules in one .js file use the RequireJS bundles config property:

@Contribute { serviceType=RequireJsConfigTweaks# }
static Void contributeRequireJsConfigTweaks(Configuration conf) {
    conf["app.bundles"] = |Str:Obj? config| {
        bundles := (Str:Str[]) config.getOrAdd("bundles") { [Str:Str[]][:] }
        bundles["myModules"] = "moduleId1 moduleId2 moduleId3".split
    }
}

Note that when doing so, your module define() functions need to specify their module name:

define("moduleId", ["jquery"], function($) { ... }