yeoman / generator-angular

Yeoman generator for AngularJS
http://yeoman.io
5.73k stars 1.44k forks source link

Remove superfluous .htaccess file #849

Closed aendra-rininsland closed 10 years ago

aendra-rininsland commented 10 years ago

The app/ folder has a really bizarro .htaccess file, which totally had me and three IT folks scratching their heads about why stuff was redirecting to a different domain (It strips the "www" from domains or something).

  1. How necessary is this .htaccess file to run AngularJS apps? My experience, from having run it via light webservers, Nginx, gh-pages, S3, etc.(i.e., "things that don't understand .htaccess files"), is not at all.
  2. If it is indeed superfluous, that file should be nuked from low-earth orbit. Seriously, realising that folder had a .htaccess file was a massive WTF moment.
eddiemonge commented 10 years ago

Apache is still the most used server, and that file has the most common rules to make sites better. If your project doesn't need it, remove it from your app folder.

aendra-rininsland commented 10 years ago

@eddiemonge Not to be obtuse, but the point about Apache's market share is kind of irrelevant. That .htaccess makes some very specific assumptions, and is based on the HTML5 Boilerplate .htaccess. Neither Bootstrap nor AngularJS (the two main dependencies of this generator) come with any sort of .htaccess file. I honestly have no issue whatsoever with Apache; I use it quite frequently myself. I'm more worried about a hidden file screwing up configurations and being hard to troubleshoot.

  1. It enables CORS images within Canvas. This may or may not be desirable, but kind of seems like a bit of an edge case.
  2. It enables CORS for webfonts. This might open a site up to legal issues if they have custom fonts (My employer, for instance). I have no idea why this is desirable in any situation; again, it seems like an edge case.
  3. It forces IE to render in the highest available mode. This is probably desirable, but I can imagine it making troubleshooting IE-related issues really difficult for somebody.
  4. The bit about forcing/suppressing www is really worrisome and could conflict with Apache config higher up the chain (such as was my issue yesterday).
  5. It does some stuff with compression, which, again, may interfere with other settings.

Again, .htaccess is a hidden file and it's not in the project root — it's in the app/ folder. I've built half a dozen things with this generator and honestly had no idea that file was there.

If deleting it altogether is too harsh, might I suggest an alternative? Rename it to htaccess.txt. That way, users who want to make use of it can simply rename it to .htaccess and it's more visible. Thoughts?

eddiemonge commented 9 years ago

It should probably be switched to match what we did in generator-webapp, but that still leaves it as .htaccess

You are right that it is based on the H5BP. A lot of time and experience has gone into making it is what it is based on a lot of feedback so I don't want to change anything on it.

aendra-rininsland commented 9 years ago

@eddiemonge Fair enough. It probably really only caused me problems because my generator-angular-based project gets pulled into a WordPress plugin via Bower as a dependency, and was conflicting with WordPress' .htaccess as a result. If anything, it's just a bit surprising that it's there, considering one generally doesn't think of AngularJS as having anything server-side involved.

Thanks for getting back to me!

eddiemonge commented 9 years ago

the team talked a little about this today. nothing resolved came out of it but the idea is floating around now

arthurvr commented 9 years ago

I think we should reconsider this. We did it for both generator-webapp and gulp-webapp: https://github.com/yeoman/generator-webapp/pull/498 and https://github.com/yeoman/generator-gulp-webapp/pull/262.