Bower: Installing Bootstrap without jquery

    For one of my projects I was using AngularJs and UI Bootstrap. Which converts all the jquery code to angular code and adds some helpful directives. From what I notice with bower was that I couldn't install bootstrap without jquery. Since it was a dependency of bootstrap.
   Note, I'm still working on this! It's important for me publish this since I've gotten so far with it. As started out I thought what I could do was to install the bower components and then try to exclude jquery in a separate folder. However in another article I will look at a better solution. Which will be where just ignore the jquery and combine the files I want. However I can see reasons for both approaches. Like in my case I wanted to remove some nuget packages and then pass off that task to bower, which I think is now how Asp.net vnext is doing it. In my case though there was too many views names js/css files and just too many js and css files.
    So this first part isn't much but I think it could help someone if they are going down the same path. Also I think this is a little whacky with how I did this and I aware of a bower packages that does this already but I didn't want to deviate from bootstrap's main bower package. Originally I was using grunt-bower-installer (now know as grunt-bower-wiredep) I noticed that there no way opting out of dependencies in bower. The following worked with "grunt-bower-installer"

//package.json file
"exportsOverride": {
    "bootstrap": {
      "../Content": "**/**/*.css",
      "../Content/fonts": "**/fonts/*"      
    },
    "jquery": {
      "../Scripts": "Exclude" //<--- throw away folder!
    }
}
//Gruntfile.js file
bower: {
            install: {
                options: {
                    targetDir: '../Catalog/Exclude',         
                    layout: function (type, component) {
                        var renamedType = type;
                        if (type == 'js') renamedType = 'Scripts';
                        else if (type == 'css') renamedType = 'Content';
                        else if (type == 'woff') renameType = 'Content';
                        return path.join(renamedType);
                    },                                
                    install: true,
                    verbose: false,
                    cleanTargetDir: true //Have fun, cleanup when you're done.
                }
            }
        }
}

How it works?
    What's happening is that I'm point to a directory for my bower components but splitting some of the files off to different places. I do this in the bower.json and point back a directory, then to the real place I want them. Leaving just the stuff I don't want in the "Exclude" folder. After all is said and done I clean up the target directory. This solution after I tested it still working with an alternative project called "grunt-bower-task". If need to see it in action just go to my github and look at my project "Catalog-Demo".

Notes
     I'm pretty sure there's better ways and I'm working on one as I finish this article. I just thought this little trick might be help to remember down the road. grunt-preen - not sure where this project is going but it is something to watch. What confused me earlier on in my development was .npmignore and .bowerignore which are more for publisher.

Why I didn't use grunt-contrib-copy
    I thought about using this project instead of going about the way I did however I think I would still need to use one of the bower tools to install bower. Which would only put the bower components in by defaults libs then from there copy them over and filter out jquery. Both are around a about around way so I figured if I'm going to move the files I might as well do it once and clean up afterwards.

Resources 
http://addyosmani.com/blog/checking-in-front-end-dependencies/ 
http://simonsmith.io/managing-bower-components-with-grunt/
"ignore" in Bower's bower.json? - Stack Overflow -

Popular posts from this blog

Aspetcore: NLog with Postgresql

Mongodb Cheatsheet

Installing Windows on Acer chromebook 15 cb3-532