Git Product home page Git Product logo

grunt-bower's Introduction

grunt-bower

Copy bower installed components to dist folder.

Getting Started

Install this grunt plugin next to your project's Gruntfile.js with: npm install grunt-bower

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-bower');

Documentation

To your Gruntfile.js, add:

bower: {
  dev: {
    dest: 'dest/path'
  }
}

Add stripAffix option if you'd like to have lib names with its file type affix to be stripped, things like /\.js$/, /js$/ or /\.css$/ etc.:

bower: {
  dev: {
    dest: 'dest/path',
    options: {
      stripAffix: true
    }
  }
}

stripAffix could cause name confliction, use with caution! If you were using grunt-bower prior to v0.9.0, stripJsAffix is now an alias to stripAffix option.

If you want to assign different destination folder for other file types:

bower: {
  dev: {
    dest: 'dest/',
    js_dest: 'dest/js',
    css_dest: 'dest/styles'
  }
}

File types without a [file_type]_dest will go to dest folder.

If you want to have more specific dest options for certain packages:

bower: {
  dev: {
    dest: 'public/',
    css_dest: 'public/styles',
    options: {
      packageSpecific: {
        bootstrap: {
          dest: 'public/fonts',
          css_dest: 'public/css/bootstrap'
        }
      }
    }
  }
}

If grunt-bower not copying the files you want:

bower: {
  dev: {
    dest: 'public/',
    options: {
      packageSpecific: {
        'typeahead.js': {
          files: [
            "dist/typeahead.bundle.js"
          ]
        }
      }
    }
  }
}

You can ignore some packages if you don't want them to be copied:

bower: {
  dev: {
    dest: 'public/',
    options: {
      ignorePackages: ['jquery']
    }
  }
}

If you want the exported files to be organized by package, use expand option. For example, such config will result in the file structure like this:

bower: {
  dev: {
    dest: 'public/vendor/',
    options: {
      expand: true
    }
  }
}
/public
  /vendor
    /package1
      package1_file1.js
      package1_file2.js
      package1.css
    /package2
      package2.js
      package2.css

Or organized by file type in addition:

bower: {
  dev: {
    dest: 'public/',
    js_dest: 'public/js/'
    css_dest: 'public/css/',
    options: {
      expand: true
    }
  }
}
/public
  /js
    /package1
      package1_file1.js
      package1_file2.js
    /package2
      package2.js
  /css
    /package1
      package1.css
    /package2
      package2.css

For file path expansion (globbing):

bower: {
  dev: {
    options: {
      packageSpecific: {
        'jquery-ui': {
          keepExpandedHierarchy: true,
          stripGlobBase: true,
          files: [
            'ui/minified/jquery-ui.min.js',
            'themes/base/minified/**'
          ]
        }
      }
    }
  }
}

keepExpandedHierarchy default to true, you have to explicitly set it to false if you want a flattened output structure.
Set stripGlobBase to true if you only want to keep the expanded part in the globbing pattern.

Change Logs

Check here.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

License

Copyright (c) 2012 curist Licensed under the MIT license.

grunt-bower's People

Contributors

curist avatar artch avatar salttis avatar ertrzyiks avatar zappan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.