Read the statement by Michael Teeuw here.
Javascript equivalent of @import in css
-
@DDE12 there is no way to do what you want in the FINAL config.js
one can make a preprocessing step that handles the imports/requires, and produces the final config.js
we have discussed using this approach for variable substitution, (hide userids/password/apikeys…), without having to interntegrate all that code into the MM base
see https://github.com/MichMich/MagicMirror/issues/1756the ‘issue’ in that the code loads config.js into the webpage as part of a <script> tag… so all pre-processing has to be done before the file is loaded… and it has to be ‘on filesystem’, unless there is a fetch hook added to check for this one filename and handle it differently
technical debt just gets deeper and deeper as you think about solving different problems here… priacy/security/modularization(yours)/etc…
edit: editor thought script tag as a REAL script tag and deleted all the content after
-
@sdetweil said in Javascript equivalent of @import in css:
the ‘issue’ in that the code loads config.js into the webpage as part of a
Did you have more to discuss?
I read through the link you posted and the possible solution there and did not see a clear solution that I could follow and tweak. I’m just a tinkerer. I tried your MMM-Config early on but was getting some unwanted results and went away from it. I might work with it again and how it goes. I also thought I could use the expand/collapse feature Notepad++ and put the name of the module after “{”. Notepad++ also has a bookmark feature (that’s the blue dot next to the line 51 indicator) and I think there is a plug-in to extend the bookmark capabilities.
.Ultimately, I’m trying to have the config.js be a little cleaner and make it easier work through so I am not scrolling through all the lines of code looking for the module section I need. Which, in turn, will help prevent spikes in my blood pressure :face_with_steam_from_nose: . Thank you for looking at this and explaining what the code is doing.
-
@DDE12 show me the issues w mmm-config.
I try to discover every modules usage thru defaults, but many are unclear or undocumented… but I provide a way to get clean content in the form, but it takes a little work.
I can ship the schema file in MMM-Config if the module is abandonedthere are lots of old, unmaintained modules
-
@sdetweil said in Javascript equivalent of @import in css:
but many are unclear or undocumented…
there are lots of old, unmaintained modulesAnd yayhoos like me making modules. :beaming_face_with_smiling_eyes:
If I start using MM-Config again and find some oddities, I will post separately so it’s not “hiding” under this topic. -
@DDE12 thanks… and can open issue in module…
an example fun time
in defaults foo: false, // must be boolean?
later
if(this.config.foo) element.innerHtml=this.config.foo // no is a string