yatskevich / grunt-bower-task

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

specifying exportsOverride still copying all deps, even dev-deps ? #110

Open sebdavid opened 10 years ago

sebdavid commented 10 years ago

Hi,

I'm trying to use exportsOverride, but I don't manage to skip the copy of devDependencies. I'm using v0.3.4. Here is my bower.json :

{
  "name": "MyProject",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "jquery": "~1.10.2",
    "bootstrap": "3.1.1",
    "lodash": "~2.3.0",
    "angular": "1.2.14",
    "angular-route": "1.2.14",
    "angular-animate": "1.2.14",
    "angular-touch": "1.2.14",
    "angular-bootstrap": "0.10.0",
    "font-awesome": "4.0.3",
    "less": "~1.7.0"
  },
    "devDependencies":{
        "angular-mocks":"1.2.14"
    },
  "exportsOverride": {
    "jquery": {
      "/": "jquery.min.js"
    }
}

I willingly removed some of the exportsOverride element to show the problem. Here is my Grunt config task :

bower: {
    install: {
        options: {
            install: true,
            copy: false
        }
    },
    assets: {
        options: {
            install: false,
            copy: true,
            cleanTargetDir: true,
            targetDir: 'src/assets/',
            layout: 'byComponent'
        }
    }
}

When running grunt bower:assets, all the dependencies are copied to src/assets : copying the files specified in the main attribute, or all the folder content (font-awesome for instance).

I thought that only elements specified in exportsOverride would be copied in targetDir (only jquery in my example), as specified by https://github.com/yatskevich/grunt-bower-task/issues/27, and in the doc : "When you define "exportsOverride" only asset types and files specified by you will be copied to ./lib"

yatskevich commented 10 years ago

You're right. The docs are a bit misleading here. grunt-bower-task will leave only needed assets for components declared inexportsOverride, but will fallback to default Bower's strategy for other components. Take a look at bowerOptions, probably you want to use production: true.

sebdavid commented 10 years ago

As the options.bowerOptions.production is only used when options.install=true, the only way to have all the assets copied in the target dir, and to have the ability to reference dev-deps (for testing) is to :

  1. run bower install with production=true and copy assets to target dir
  2. clean bower components folder
  3. re-run bower install with production=false Am I right ? It would be more "simple" (no need to download the dependencies twice) if there was an option or something to act only on dev-deps or only on deps. But, the production option solved my problem. Thanks !
joepuzzo commented 8 years ago

I did the following:

"exportsOverride": {
    "angular": { 
        "js": "angular.min.js*"
    },
    "angular-route": { 
        "js": "angular-route.min.js*"
    }, 
    "angular-bootstrap": { 
        "js": "ui-bootstrap.min.js"
    }, 
    "bootstrap": { 
        "css": "dist/css/bootstrap.min.css*"
    }, 
    " * ": { 
    }

By matching everything and mapping it to nothing only the things specified will get copied over.