m0dch3n / vue-cli-plugin-cordova

Vue Cli 3 Cordova Plugin
MIT License
417 stars 63 forks source link

cordova_plugins.js is not found when serving browser #6

Closed eladcandroid closed 6 years ago

m0dch3n commented 6 years ago

During the plugin development, I was not sure, if these files are needed to be served or not, in vue cli development mode...

For a production build, you shouldn't normally see this error...

For the dev mode, the easiest and best way, to solve this problem, would be, to let us set, the contentBase of the devserver

I already created a pull request therefore

https://github.com/vuejs/vue-cli/pull/2487

In the meantime, we could maybe try to rewrite the middleware I use...

Currently it is hardcoded:

const cordovaJSMiddleware = () => {
    const cordovaJSPath = getPlatformPathCordovaJS(platform)
    const cordovaJS = fs.readFileSync(cordovaJSPath, 'utf-8')
    return (req, res, next) => {
      if (req.url === '/cordova.js') {
        res.setHeader('Content-Type', 'text/javascript')
        res.send(cordovaJS)
      } else {
        next()
      }
    }
  }

A solution would be, if the url exists in platform/platform_www/ then serve it...

m0dch3n commented 6 years ago

Can you please try release 2.0.2, if this works better now?

eladcandroid commented 6 years ago

@m0dch3n You're great! Thanks! I can check only on Friday because we have a holiday here in Israel..

eladcandroid commented 6 years ago

Checked it now and it works. Great job! thanks!