I would like to load a Vue.js application into an existing webpage via script tags.
Currently after running npm run build inside of my Vue application, I get 7 compiled files:
- app.js
- app.js.map
- manifest.js
- manifest.js.map
- vendor.js
- vendor.js.map
- app.css
I thought I could load those 3 js files (manifest, vendor and app - excluding the map files) as the source in script tags on my separate webpage and the Vue application would then exist on that webpage.
(I would also load the css file on the page but I am not worried about that currently.)
After attempting to inject the 3 js files in script tags (as the src), I see the js files do exist on page as sources, but it does not seem the Vue application is ever 'executed' and no DOM elements from the Vue application exist on the page.
I also loaded the vue.js (development version) js file via a script tag on the page as well.
I am not extremely familiar with web-pack but I suspect there is something that needs to be done to execute web-pack to run the Vue application within this separate webpage since web-pack is what is used to run the Vue application locally on its own.
I am unsure if this is even possible but I am unable to find any resources that demonstrate what I am trying to achieve.
Please provide any help or information that is relevant and if this is even the correct way to go about running a Vue application within a third party webpage.
EDIT
This is the js code used to insert the script tags with the src of the files:
var head = document.getElementsByTagName('head')[0];
var js = document.createElement("script");
js.src = "/js/app.js";
head.appendChild(js);
I use this code for each of the files (app, manifest and vendor). This is all I do and the script tags exist on page with the correct sources. Under the sources tab in my Chrome debugger I see all three js files being loaded correctly.