I’m trying to automatically inject my bower components into www/index.html. I got the index.html file populated but I’m getting 404’s for all of the files. When I run ionic serve - is it creating a webserver from the www folder (thus preventing access to the bower_components folder at the root? Do I have to copy all of the bower components into the www folder? I remember the initial setup having a www/lib folder with the libs copied and pasted in there. This isn’t easily maintainable though so I’m trying to use wiredep instead.
Here’s the generated index.html. So theoretically the path is correct - it’s trying to reach outside the www folder and into the bower_components folder - but I’m assuming it can’t because it’s a web server.
You want to see the gulp config - what is this? Here’s my gulp code for wiredep:
Thanks @swade for your help so far. I really appreciate it. Got some questions:
What is my “config”? ionic.project in the root?
Are you suggesting that I do have to manually copy over the bower components into www/lib so that index.html can pick them up and not just reference them from outside of the www folder?
I have the config as a gulp.config.js file and require it in my gulp file. You could just as easily put it in your gulpfile. You don’t have to manually do it, wiredep has options to ignore path names and replace them. So that file type is actually used when wiredep injects it into your html. So essentially with this '<script src="/lib/{{filePath}}"></script>', it should ignore ../bower_compenents in your filepath name then you can add your own filepath prefix, in this case /lib/.
Oh, I get what you’re asking. Mine automatically add to the www/lib folder when I do a bower install, but I don’t think it really matters if they are in the www filepath, but cordova might have something to say about that. But you can choose your directory in the .bowerrc file.
The problem here is that I’m trying to treat the www as a target folder where only compiled and built files go. I’ve extracted my application out of the www folder into an app folder at the root so I can more easily manage the src files and built files. The problem is getting the bower_components into the target (www) directory.
In the www folder you should just put your build, with the assets compiled, concatenated and obfuscated in a vendor.js/vendor.css (the bower stuff) along with your app.js/app.css (your app files).
Check this structure. If you follow best practices you’ll end up with a very similar structure to that one. It’s based on Swiip’s gulp-angular. Give the generator-m a go, check the build tasks, and study how it’s built.
Not sure why you are re-structuring your project, understand you are wishing to use www as your compiled directory, however when you build your ionic application it gets copied into platforms/ios/www (for example) you’ll have issues with the default ionic config due to restructuring your project.
You should treat this directory as your compiled/distributed directory, app_root/www is your working development directory.
@Loyx Yep, I saw that generator before but that generator doesn’t follow the best practices that you linked to (or I’m doing in my app). They’re doing the typical directives.js and services.js - not organizing by module/component. I did figure out how though to get the bower files injecting and solved that issue and have effectively turned the www folder into a build directory. Exactly what I wanted.
@delta98 The reason I’m restructuring my project is that I don’t want my build files sitting next to my src files. This separation makes it much easier for maintaining in a variety of ways. I have pulled this off without any problems and it seems to be working great. Did some builds and all is working on the devices.
In a module structure, controllers and directives shouldn’t be in a controllers/directives folder but in the module folder. Right? Am I reading this right?
Right, but you still have the “controllers” folder. Scroll down in that best practices doc to the “A More Complex App Example”. You’ll notice the controllers are inside of the module, not a controllers folder. That’s more of the approach I meant and the m-generator doesn’t seem to be talking about that pattern.