scotch / angular-brunch-seed

AngularJS + Brunch
Other
228 stars 78 forks source link

Official bower support #75

Closed paulmillr closed 10 years ago

paulmillr commented 10 years ago

It’s there. I think we can drop plugins

kylefinley commented 10 years ago

@paulmillr nice work, there seems to be some major speed improvements in v1.7, too.

Are there restrictions on the name of the bower components directory? I've tried various things, but I'm not able to get bower to read the js files. Actually I can't get bower to join any files that are not in either app, vendor, or test. I think I most be missing something obvious, because you appear to be compiling components from bower_components in chaplin.

Do you have any thoughts on what I might be doing wrong. Thanks for the help -- I'm looking forward to the upgrade.

paulmillr commented 10 years ago

yeah currently only bower_components directory is supported (default in Bower 0.10+), i’m looking forward for adding support of bower config file that will allow to specify it.

paulmillr commented 10 years ago

Keep in mind that by default some packages don’t have main or dependencies properties in bower.json. Which means it’s impossible to know which files should Brunch compile. And we don’t want brunch to watch all 100 possible package files.

Grunt and other solutions want you to specify all files.

But when I decided to solve that, I’ve implemented overrides property in root bower.json: https://github.com/paulmillr/brunch-with-chaplin/blob/master/bower.json#L19-28. I hope it will become standardised.

Basically it allows to specify order and files in packages. Which allows to automatically order them for concatenation correctly, you don’t even need to set order in config.coffee

kylefinley commented 10 years ago

Ok, that helps.

So, how does overrides work? I'm trying to install bootstrap. If I add:

  "dependencies": {
    "bootstrap": "~2.3.2",
  },
  "overrides": {
    "bootstrap": {
      "main": [
        "docs/assets/js/bootstrap.js",
        "docs/assets/css/bootstrap.css"
      ],
      "dependencies": {
        "jquery": "*"
      }
    }
  }

When running brunch watch I get:

14 Jul 08:49:22 - error: [Error: Error: Component must have "/Users/finley/github/angular-brunch/angular-brunch-seed/bower_components/bootstrap/bower.json"

If i remove bootstrap from dependencies bootstrap does not install with bower install

paulmillr commented 10 years ago

So, basically you don’t have any bower.json in the bootstrap. i’ve thought it’s auto-created. What bower --version is yours?

kylefinley commented 10 years ago
bower --version
0.10.0

Bootstrap is still using component.json so it doesn't have a bower.json file.

kylefinley commented 10 years ago

I just found a bootstrap-less that I think will work with bower 0.10.0. So, If this use case isn't covered please don't worry about it -- Brunch shouldn't have to worry about working with the depreciated component.json. Sorry for the noise, I just thought that overrides allowed for this usecase.

kylefinley commented 10 years ago

@paulmillr

Impressive release!!

added brunch 1.7.4--pre support 4cffcba08874a5b101fb0ffd9b85f63576804ff6

Thank you for all of your hard work!

paulmillr commented 10 years ago

component.json isn’t supported because it’s used by component(1) and because you can usually submit renaming pull requests to repos where it’s located (because they were early adopters and are more likely to accept it as compared to folks who don’t want bower at all).

On the other hand, bower 1.0-pre (npm install bower-canary) automatically creates .bower.json for any repo. Which means you will be able to use old repos too.

kylefinley commented 10 years ago

That makes sense. I didn't realize that bower 1.0-pre creates the .bower.json files automatically, I'll investigate using it instead of0.10.0. Thanks for the information.