Manifest custom load rule

Manifest custom load rule defines when the manifest must be loaded in some special conditions.

There are 2 system load rules, as described below, will not be affected by any custom load rules.

  • A web-component manifest will be loaded as soon as its element exists in the DOM.
  • A resource manifest will be loaded when it is imported in another manifest that's being loaded.

It's IMPOSSIBLE to unload loaded manifests.


  • script.ts
alert('script is loaded');
  • resource.manifest.ts
import { Composer } from '@omnia/tooling/composers';
import { OmniaResourceManifests, OmniaService } from '@omnia/fx-models';

    .registerManifest(new Guid(guid-id), "resourcemanifest")
    .registerResources({ resourcePaths: ["./script.ts"] })

    //Load If a feature is activated
    .loadIfFeatureActivated({ featureId: feature-id })

    //Load If a manifest is loaded (e.g. Load in SharePoint)
         resourceId: OmniaResourceManifests.SpfxCustomizer.toString(), 
         omniaServiceId: OmniaService.Id.toString()

    //Load If a DOM matching (e.g. Load in Omnia)
        cssSelector: 'div[id="omnia-app"]'

    //Load if a query string exists is url (e.g. load when https://....?load=true)
        regEx: ".*?(load=true)"
    //Always load
        startsWith: "/"

    //Load by user matching (e.g. load for AzureAd user)
    .loadByUserMatching("type", UserTypes.AzureAdInternalUser)

    //It is possible to combine rules (e.g. load when 2 feature is activated)

    //find more details in the interfaces