MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

mergeConfig() function

  • Module Developer


    Hi, this kind of script can help developer to merge userconfig and default module config.
    I use it in my ALL modules !
    I make it public in a way to help you 😉


    In main module core, you can put it in start() function

    this.config = configMerge({}, this.defaults, this.config)

    your default config will be merge with defined user config !
    If the defined user config don’t define all config value (minimal config for exemple), this script will merge it to do an entire config
    So you can send your config to node_helper.js without fear of having undefined values

    Arg Number Function
    Arg 1 Initial objet
    Arg 2 Config model
    Arg 3 Config to merge

    Load the script in MagicMirror

    You have to load the script on the main core of your module

    getScripts: function () {
      return [

    Why using it ?

    Object.assign() function don’t to all job

    it don’t merge all thing in depth

    -> object in object and array is not merging


    You can also use the Minified code version mergeConfig.min.js

    How download it:

    In your terminal use the wget command


    or for Minified version


  • @Bugsounet I don’t understand

  • Module Developer

    I will code a sample wait 😉

    LoOOooL, now this script is not needed 🙂
    now MM v2.12.0 have solve this issue 🙂
    but still in v2.11.x

    I understand why you say i don't understand

    I see this at now, pfff i don’t read ChangeLog lol

  • @Bugsounet also, _loadash lib is previously loaded, and loadash.merge does the deep merge, while Object.Assign does not.

    and it only matters for modules with big deep config structures. like GA

  • Module Developer

    it’s new because in v2.11.x, I have to use mergeConfig()

  • @Bugsounet lodash.merge loaded before 2.12.

    just saying it’s easy, if u need to do this, without another script

Log in to reply