cordova.js not found when building for web



  • I’m building a chrome extension, and all seems fine during development. When packing it though (npm run build) and loading the extension, i get a cordova.js net::ERR_FILE_NOT_FOUND

    Opening the vendor.js i see a void(e.src="cordova.js") which begs the question why is cordova requested in the web build and why it works fine outside the chrome environment.

    Any ideas?



  • After some digging, i found out that the problem is that the app is being detected as cordova although it isn’t. What could be triggering the following code?

    if(te.is.cordova&&!te.within.iframe){var e=document.createElement("script");return document.addEventListener("deviceready",t,!1),e.type="text/javascript",document.body.appendChild(e),void(e.src="cordova.js")}
    


  • Platform.is output

    chrome : true,
    cordova: true,
    desktop: true
    name: "chrome"
    


  • So, the problem is in quasar.common.js here

    else if (window._cordovaNative || document.location.href.indexOf('http') !== 0) {
        browser.cordova = true;
      }
    

    Apparently, when in chrome extension document.location.href.indexOf('http') !== 0 is true, so browser.cordova becomes true and then it tries to load the cordova.js


  • Admin

    Solved. Available in edge and future v0.14. Github ticket: https://github.com/quasarframework/quasar/issues/485



  • Tried with the edge build but there is still an attempt to load cordova.js if the index.html is loaded locally “file://” .
    I realize that when you do a build with quasar, it clearly states that the dist folder cannot be loaded via “file://” but there is one use case where loading from file:// could be helpful - When you have a heavy ( 1mb +) webapp and so you want to package it along with a native app, for performance reasons. So, the webview in the native app simply loads the index.html. Currently, this won’t work since the loading will trigger the injection of the ‘cordova.js’ reference.

    Would be great to have a switch in build that allows the 'file://" based loading of index.html to happen on a mobile.


  • Admin

    Don’t have time now to investigate, but I will. In a few days max. Thanks for your patience.


  • Admin

    @mbouclas On a chrome extension, what does console.log(document.location.href) say?


Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.