Is there a way to deploy some code for the web (React) and deploy another different piece of code (Vue) for mobile? Just curious. Thank you all in advance.
Asked
Active
Viewed 19 times
1 Answers
0
You can dynamically create script
tag with src
set to correct app bundle (either react
, either vue
):
<script type="text/javascript">
const appScript = document.createElement('script');
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// Mobile, put path to vue.js app bundle
appScript.setAttribute('src','path/to/vue/app/bundle');
} else {
// Desktop, put path to react.js app bundle
appScript.setAttribute('src','path/to/react/app/bundle');
}
document.head.appendChild(appScript);
</script>
Note: this answer is combined from those two:

Klimenko Kirill
- 634
- 2
- 8
- 22