npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bower-mapper

v1.0.6

Published

Grunt task to (concatenate and) copy bower components depends on map file

Downloads

9

Readme

bower-mapper

Grunt task to (concatenate and) copy bower components depends on map file

Overview

Most of bower components have their minified versions and resources (fonts, images etc.) in their file structure. To copy required files, you can define them in your grunt file but it may hard to handle. By that library, you can define a grunt task to select required libraries and resources as well as concatenation option.

Getting Started

Installation:

npm install bower-mapper --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('bower-mapper')

The "mapper" file

Overview

You can define bower components and sub categories via mapper file.

Simple "bower.mapper.json" file

{
    "jquery": {
        "js": { "dist/jquery.js": "dist/jquery.min.js" }
    },
    "bootstrap": {
        "js": { "dist/js/bootstrap.js": "dist/js/bootstrap.min.js" },
        "css": [
            { "dist/css/bootstrap.css": "dist/css/bootstrap.min.css" },
            { "dist/css/bootstrap-theme.css": "dist/css/bootstrap-theme.min.css" }
        ],
        "fonts": [
            "dist/fonts/glyphicons-halflings-regular.eot",
            "dist/fonts/glyphicons-halflings-regular.ttf",
            "dist/fonts/glyphicons-halflings-regular.woff"
        ]
    },
    "angular": {
        "js": { "angular.js": "angular.min.js" }
    }
}

There is 3 diffirent supported node type.

Node types

  1. Object type

    { "dist/jquery.js": "dist/jquery.min.js" }

    In that format, key stands for path of original file and value for its minified version. All dependencies resolved by root key name and it should match to downloaded bower component name.

  2. String type

    "angular": {
        "js": "angular.min.js"
    }

    If no futher configuration is needed, string type of node can be used for defination.

  3. Array type

    "fonts": [ "dist/fonts/glyphicons-halflings-regular.eot",
            	"dist/fonts/glyphicons-halflings-regular.ttf",
            	"dist/fonts/glyphicons-halflings-regular.woff" ]

    This format can be used for multi selection like font or other kind of resources (images, icons etc.)

Component types

By default, "bower-mapper" uses bower_components directory to resolve resource however you can add node_modules directory to resolve also npm packages. Resolve order is same as declaration order.

The "bower-mapper" task

Overview

In your project's Gruntfile, add a section named "bower-mapper" to the data object passed into grunt.initConfig().

grunt.initConfig(
    'bower-mapper': {
        options: {
                mapper: "bower.mapper.json",
                components: ["bower_components", "node_modules"]
        },
         js: {
             src: ["underscore", "jquery", "bootstrap", "angular", "angular-animate", "angular-route"],
             dest: "libs.js",
             concat: true,
             useMin: true
         },
         css: {
             src: ["fontawesome", "bootstrap"],
             dest: "css",
             useMin: true
         },
         fonts: {
             src: ["fontawesome", "bootstrap"],
             dest: "fonts"
         }
    }
)