yatskevich / grunt-bower-task

Grunt plugin for Bower
MIT License
490 stars 117 forks source link

Does not produce files "by type" #75

Open melcher opened 11 years ago

melcher commented 11 years ago

Just running the default task, both with no options and with manually setting layout to "byType", it does not group the files by type. Hoping someone can help!

$ grunt bower
Running "bower:install" (bower) task
>> Installed bower packages
>> Copied packages to ~client/lib

Done, without errors.
$ ls ~client/lib
angular       angular-mocks bootstrap     jquery

My Gruntfile.js

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bower: {
      install: {
         //just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory
        options: {
          targetDir: './client/lib',
          layout: 'byType',
          cleanBowerDir: false,
          install: true
        }
      }
...
yatskevich commented 11 years ago

@melcher I see. Let me explain - the word type in byType layout refers to sections in exportsOverride. Consider the following example from docs:

  "exportsOverride": {
    "bootstrap-sass": {
      "js": "js/*.js",
      "scss": "lib/*.scss",
      "img": "img/*.png"
    },
    "requirejs": {
      "js": "require.js"
    }
  }

js, scss, img - are types. Please note, that type ≠ extension. The following line from the example demonstrates this fact: "img": "img/*.png".

byType layout will not work until you describe override rules for your libraries in exportsOverride section.

By the way, we see that our current wording causes a lot of confusion, so we are going to improve docs / restructure the task itself to make it more user-friendly.

reggi commented 11 years ago

Basically without an override there is no type because nobody specifies main files in bower by type (yet).

heruan commented 11 years ago

@reggi how one could specify main files by type in bower.json?

reggi commented 11 years ago

@heruan Not sure what you're asking.

In bower.json you can set for example "main": "path/to/main.css" but I don't think there's support for / nobody ever sets "main" files by type for instance like this:

"js": "js/*.js",
"scss": "lib/*.scss",
"img": "img/*.png"
blbradley commented 10 years ago

I understand @melcher's confusion. exportOverrides is under the Advance Usage section of the documention. I feel like this leads the user to think that they get the directory structures specified under byType and byComponent for free. With my initial usage, byComponent is used even if layout: 'byType' is set (without setting exportOverrides).

Maybe having the directory structure for a few common types (js, css, fonts, images) baked into byType would help? Mostly taking cues from the Rails asset pipeline.

melcher commented 8 years ago

Ah yes, makes sense. I definitely assumed it would do basic asset-type matching by extension without needing to specify it per-library. Thanks.

codewithtyler commented 8 years ago

@melcher did this solve your problem?