m0dch3n / vue-cli-plugin-cordova

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

Need to expose config.xml on root #70

Closed caiotarifa closed 5 years ago

caiotarifa commented 5 years ago

Hi,

Use cordova-plugin-splashcreen required cordova/confighelper that try access /config.xml via XHR (line 69).

So, there is a way to expose src-cordova/config.xml as /config.xml?

Thanks, Caio

caiotarifa commented 5 years ago

Solved editing vue.config.js with this:

const path = require('path')

module.exports = {
  chainWebpack: config => {
    config.plugin('copy').tap(args => {
      const copyCordova = {
        from: path.resolve(__dirname, 'src-cordova/config.xml'),
        to: args[0][0].to
      }

      args[0].push(copyCordova)
      return args
    })
  },

  ...
}

What about add it on template generator?

m0dch3n commented 5 years ago

Sorry, but I don't see a general usage case, where the config.xml needs to be accessible by XHR, except for your cordova plugin...

Also if you just npm build your vue app for the browser, you don't need any cordova stuff at all, nor does everybody need to adapt the cordova-plugin-splashscreen, so I think your approach is the best way to solve your specific problem.

caiotarifa commented 5 years ago

@m0dch3n well, cordova-browser exists and the official way to get the config.xml is via XHR.

https://github.com/apache/cordova-browser/blob/master/cordova-js-src/confighelper.js

I use cordova-browser instead of npm build by convenience. All things works because they expose window.plugin and window.cordova. And it's really useful for development.

Not trying to change your mind but I really think this setup should be part of this generator.

Dinthi commented 5 years ago

I ran into the same problem. The config.xml is not in the root so cordova/confighelper never returns preferences.

My workaround was to create a new config.xml with the settings i needed in the /app/ folder and use asset options in the angular.config file to move it to the root for the browser platform.