ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

ionic serve doesn't support cordova browser plugins

Open xeoncross opened this issue 11 years ago • 48 comments

Some (but not all) cordova plugins have Javascript proxies if the features they offer can also be used in a regular browser.

I'm using one such plugin and I need to access the cordova.plugins.____ object. However, the cordova.js file is a 404 when using ionic serve. It's not a 404 when using ionic build browser.

How do you access the cordova object in javascript when using ionic serve? Or do you have to ionic build browser every single time you want to see your changes?

xeoncross avatar Apr 06 '15 20:04 xeoncross

+1

movrack avatar Jun 28 '16 12:06 movrack

+1

rmx48 avatar Jun 28 '16 13:06 rmx48

+1

barlos23 avatar Jun 28 '16 13:06 barlos23

+1

virtualit786 avatar Jul 19 '16 08:07 virtualit786

+1

renanbs avatar Aug 18 '16 19:08 renanbs

+1

valix85 avatar Aug 26 '16 13:08 valix85

+1

M4rcDev avatar Aug 27 '16 21:08 M4rcDev

Facing the same issue with ionic serve. Hope this gets resolved soon. ionic run browser works for me though

selvagsz avatar Sep 02 '16 11:09 selvagsz

  • 1

vassallocarlo avatar Oct 18 '16 13:10 vassallocarlo

+1 I'm experiencing this issue as well, and it really sucks that ionic run browser --livereload does not work either.. Is there anyone on the Ionic team that is looking into this?? I haven't seen anyone from them comment on this yet.

BradyNadeau avatar Oct 29 '16 21:10 BradyNadeau

Throwing another +1 onto the heap

joshuaohana avatar Nov 01 '16 21:11 joshuaohana

+1

marcusgraf avatar Nov 04 '16 15:11 marcusgraf

This is really horrible... can you at least throw some log that that's the problem? Wasted a whole day on this...

ghost avatar Nov 07 '16 14:11 ghost

If I do a ionic build browser, I noticed that the cordova.js and it's dependencies get built to /platforms/browser/cordova/platform_www. The question is (maybe), how do we get that output via WebPack to get generated to /www? Would LOVE to know the answer to that.

morrisonbrett avatar Nov 07 '16 17:11 morrisonbrett

as mark-veenstra already wrote - but let me fix the port from 8100 -> 8000 which is the port the "ionic run browser" works:

add this to your gulp file under the other tasks:

gulp.task('browser:serve', function() {
    gulp.src(paths.browser)
        .pipe(webserver({
            livereload: {enable: true, port: 35729},
            directoryListing: false,
            host: localhost,
            port: 8000,
            open: true
        }));
});

ghost avatar Nov 09 '16 13:11 ghost

ionic run browser --live-reload throws Error loading cordova-browser for me. Does anybody knows something about this

ghost avatar Nov 17 '16 08:11 ghost

@LordPrettyFlacko I get that as well but am able to build and serve for browser (pulling in all js and hooks) with ionic build browser --desktop --testing && http-server platforms/browser/www/

joshuaohana avatar Nov 17 '16 14:11 joshuaohana

@joshuaohana i tried this but my system cant find the http-server command. However it works for me now with ionic serve browser. I dont know why cause i tried so much thing but in the end it works.

ghost avatar Nov 18 '16 09:11 ghost

What I have done as a hacky workaround for the time being is just do an ionic build browser and then I copy the platform_www folder from the platforms/browser directory into my www folder and then I reference it inside my index.html with <script src="platform_www/cordova.js"></script>. After doing that my ionic serve will then load all my cordova browser plugins.. (Works 90% of the time, i usually just refresh my page if the plugins don't load on initial startup.)

  1. ionic build browser
  2. copy platforms/browser/platform_www folder to www folder
  3. add <script src="platform_www/cordova.js"></script> to index.html
  4. ionic serve (refresh page if plugins don't load at first.)

BradyNadeau avatar Nov 23 '16 13:11 BradyNadeau

By using "ionic run browser --livereload" command I can see the trigger is active: "HTML changed: www\index.html"

however we need to run a command to compile our changes:

cordova prepare browser

I hope someone can fix it ASAP.

dgofman avatar Dec 01 '16 20:12 dgofman