Hey,
I am not entirely new to moodle plugin development, however my javascript code in plugins were my own custom AMDs so far. As I am concentrating on quiz plugin development right now, I would like to incorporate any single page application framework for the participant facing part of my plugins. For quiz plugins it's rather annoying to have constant page reloads, so I figured this would be a good way to improve UX for participants (I am planning on keeping the traditional php stuff for activity configuration, like forms etc, because that would obviously be too much work to change).
Long story short, I'm trying to integrate a Vue.js application, which is built with webpack, into the view.php. When building the Vue.js application, there are 3 javascript bundles created (app.js, manifest.js and vendor.js) + 1 css bundle. The way to render the application would normally be to just include these .js and .css files into an html file and having a div with id="app", where Vue then renders the app. My problem is that I don't have any clue how to include the .js files. The way to do this in moodle would normally be to have an AMD file and an init function inside the AMD. Although it is possible to deploy javascript as AMD in webpack, it doesn't seem to be possible to surround it with a named function. And because the deployment is an automatic (and good) procress I would rather not have to fiddle something into the resulting .js files by hand.
Anyone here who has an idea how to tackle this problem? I.e. how to get the three .js files (AMD or vanilla) to be included AND executed when rendering view.php?
Thanks in advance!
PS: I can provide the complete code if someone wants to see it. However, the packaging to a .zip file for plugin installation requires manual work right now as I didn't invest to much time into build automation in this early proof of concept work. Just say something if you want me to guide you through the code..