Can you overload a javascript file in dojo/the edit mode?

Member since: 2006

As the topic states, can you route edit mode/dojo javascript file requests to an alternative file in some sort of "official way"?

Using episerver 8+, can you in some way tell epi to instead of reading ex. the file (in EPiServer.Cms.Shell.UI.zip) "[version]\ClientResources\epi-cms\widget\FileList.js", read another file located somewhere else on disk?

And yes, I know this can break episerver in so many wonderful ways..

#122160 May 27, 2015 11:47
  • Member since: 2006

    Great success!

    Apparently I could simply add the file to the module.config file, like so:

    <add name="epi-cms.widgets.base" path="my/modified/version/of/a/dojo/file.js" resourceType="Script"/>

    And it will be used instead of the original function, I assume because the dojo system only load one "define(..." once, and mine is loaded before the original (in widgets.js). Though I fear this can sometimes break depending on the order the files are loaded.

    #122194 May 27, 2015 19:56
  • Member since: 2009

    This could lead to multiple define errors in the AMD loader. A better approach would be to use an alias. This is a bit of configuration in the module.config that says run my file instead, e.g.:

    <?xml version="1.0" encoding="utf-8" ?>
    <module>
      <dojo>
        <packages>
          <add name="my-app" location="ClientResources" />
        </packages>
        <aliases>
          <add from="epi-cms/widget/FileList" to="my-app/FileList" />
        </aliases>
      </dojo>
    </module>
    

    #122583 Jun 05, 2015 14:53
  • Member since: 2006

    Nice, this seem like a cleaner approach.

    Can you register a dojo alias programmatically?

    Edit: Ah, I seem to be lost anyways on what exactly I should set. Could you possibly write up a complete modules.config example to replace:

    [version]\ClientResources\epi-cms\widget\FileList.js

    with

    /ClientResources/myapp/FileList.js

    The files will be identical, im just trying to understand exactly how the aliases work here.

    #122591 Edited, Jun 05, 2015 16:44