calvinl / ng-phonegap

Grunt workflow for building AngularJS applications on PhoneGap.
MIT License
138 stars 28 forks source link

hardcoded appDir #18

Open jensengar opened 10 years ago

jensengar commented 10 years ago

So I couldn't figure out why grunt dev would work correctly in the browser but failed to copy all the resources to www in order to build correctly when emulating devices. I eventually tracked the error to this line in grunt.js

appDir: 'app/www',

which I am pretty sure should just be:

appDir: 'www',

When I changed it to www however, I started to get the following errors in the browser and on the devices:

GET http://0.0.0.0:9001/vendor.css 404 (Not Found) 0.0.0.0/:10
GET http://0.0.0.0:9001/app.css 404 (Not Found) 0.0.0.0/:11
GET http://0.0.0.0:9001/cordova.js 404 (Not Found) 0.0.0.0/:14
GET http://0.0.0.0:9001/endor.js 404 (Not Found) 0.0.0.0/:15
GET http://0.0.0.0:9001/g.js 404 (Not Found) 0.0.0.0/:16
GET http://0.0.0.0:9001/pp.js 404 (Not Found) 0.0.0.0/:17
GET http://0.0.0.0:9001/onfig.js 404 (Not Found) 0.0.0.0/:18
GET http://0.0.0.0:9001/odules.js 404 (Not Found) 0.0.0.0/:19
GET http://0.0.0.0:9001/irectives.js 404 (Not Found) 0.0.0.0/:20
GET http://0.0.0.0:9001/ilters.js 404 (Not Found) 0.0.0.0/:21
GET http://0.0.0.0:9001/ervices.js 404 (Not Found) 0.0.0.0/:22
GET http://0.0.0.0:9001/ontrollers.js 404 (Not Found) 0.0.0.0/:23
Uncaught ReferenceError: pg is not defined 

You'll notice the url's are cut off. I was able to track this down to the application.tmpl to find this:

<% if (env == 'development') {
     css.forEach(function(asset) {
       print('  <link rel="stylesheet" href="' + asset.substring(8) + '"/>\n');
     });
   } else if (env == 'production') {
     print('  <link rel="stylesheet" href="css/app.css" />');
   } %>

I had to fix the asset.substring(8) to be asset.substring(4) in src/html/layouts/application.tmpl in order to work. Maybe there's a better way to do this?

calvinl commented 10 years ago

Thanks for reporting this - definitely something to address. I'll file it and push a fix for it soon.