Install jquery.min.js with bower - bower

When installing a dependency with bower, how would I get the minified version of the target dependency?
Say I wanted to install jquery-1.11.2.min.js with bower what would be the command for that?

Since the minified version of jquery is install as well when running bower install jquery, you can override the main file it points to, and point it to the minified jquery file.
If you look in the bower.json of bower_components/jquery the main file is:
"main": "dist/jquery.js"
You can override the main file in your projects bower.json by adding:
{
"overrides": {
"jquery": {
"main": "dist/jquery.min.js"
}
}
}

Try to explore Grunt (JS task runner).
Bower is for dependencies management, while Grunt is designed to act on these dependencies (you can compile CSS, do tasks like minification and concat, etc). There’s a Grunt module called “grunt-bower-task” that facilitates integrating the two. Enjoy! :)

Related

How to add sass file from bower in Jekyll when using github-pages

I've been trying multiple solutions to integrate bower assets in jekyll but none seem simple enough or future safe.
One interesting solution would be to add to sass_dir all gem assets dirs from any https://rails-assets.org gem (which converts any bower repo into a assets gem automatically) but I did not find docs that says it's possible.
Or use bower and import the sass files. But without grunt.
The goal is to be able to #import sass from asset gems, push on gh-pages branch and let github deploy without any extra step.
I ended up adding the bower packages directly to the _sass dir. No special config except your .bowerrc file should point to the _sass dir:
{
"directory" : "_sass"
}
It's not ideal for big projects but in my case it fits perfectly my needs.
This solution is the simplest if you're directly pushing to gh-pages branch directly.
If you have a more complex setup and many bower packages, then I think I'd go for a custom build with 2 branches and a grunt based flow.
Then you can use sass load_paths as mentioned here https://github.com/jekyll/jekyll/issues/3366
sass:
sass_dir:
- _sass
- bower_components

How to install plugins in grails-3.2.0 which i have used in grails-2.4.4 while upgrading application

I am trying to upgrade my application from Grails 2.4.4 to Grails 3.2.0. I am having problems installing plugins used in previous version. Following Questions did gave me some clarification :
1) First one
2) Second one
Now I have few plugins like tomcat, jquery,etc which are not available at https://bintray.com/grails/plugins as described in First one question.
So can you tell me how do I add plugins which are not in this directory on plugins at bintray.
There is some problem as well I am using database-migration plugin. There is listing available at bintray and says to use it as
compile 'org.grails.plugins:database-migration:3.0.0'
as I added same in build.gradle file in my project under dependencies section. Project gets compiled successfully but does not run. Shows long exception but starting is as follows :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':bootRun'.
Please help to resolve this errors while installing plugin in Grails 3.2.0
You need an extra configuration for that plugin as its doc says.
Add in build.gradle
buildscript {
dependencies {
...
classpath 'org.grails.plugins:database-migration:3.0.0'
}
}
dependencies {
...
compile 'org.grails.plugins:database-migration:3.0.0'
}
It is also recommended to add a direct dependency to liquibase because Spring Boot overrides the one provided by this plugin
dependencies {
...
compile 'org.liquibase:liquibase-core:3.5.3'
}
You should also tell Gradle about the migrations folder
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
Maybe plugins are no longer necessary and don't have direct replacements. The tomcat plugin is not needed because Grails 3 is built on Spring Boot and the dependency:
compile "org.springframework.boot:spring-boot-starter-tomcat"
Provides tomcat already. The jQuery plugin is not needed either because you can simply declare a dependency on the jquery.js file directly using asset pipeline which is just as simple. See How to Use jQuery in Grails 3.0

Bower: Install package that doesn't have bower.json file

I'm trying to get Bower to install this javascript:
https://github.com/markmalek/Fixed-Header-Table
I use: bower install git#github.com:markmalek/Fixed-Header-Table.git --save
It installs the package into bower-components, and even adds it to my project's bower.json, but it doesn't add the to my html. I'm guessing it's because that particular git repo doesn't contain a bower.json telling my project which js file is the main one. So how do I install this package?
Thanks!
This answer takes your assumption that your HTML is picking up scripts loaded via Bower using the bower.json file as correct.
There are two options. The quickest is to fork the repo yourself, and in the main directory use the command bower init to create your own bower.json file in your forked version of the repo. Then, change the github url to the repo to your forked version rather than the original you have above.
The second option is to submit a pull request to the package owner adding a bower.json file so that you can continue to pull directly from his repo.
There are probably more options like manually loading the script outside of pulling from a bower.json file but the two above seem simplest.

Difference between `--save` and `--save-dev`

What is the difference? I realise that they get put into different object properties in bower.json but I can't seem to figure out why you need two separate properties for this, why not just use one.
From the documentation:
-S, --save: Save installed packages into the project’s bower.json dependencies
-D, --save-dev: Save installed packages into the project’s bower.json devDependencies
But there is no explanation of the difference between the two. When should I be saving in dependencies vs devDependencies?
Same case than in npm. Packages that you use in production should go inside dependencies and those that do not inside devDependencies.
The idea is that you are able to install only --production or --development variables, depending on the environment you are deploying your code.
From another answer in this community: What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

Filter (include/exclude) files for Bower dependency

I am trying to use Bower to manage client side dependencies from a Java/JSP server side application.
It works and I can access client side libraries resolved via "bower install" as described in bower.json.
However, lots of unnecessary files are added to "bower_components" as declared by the dependencies used (tests, docs, examples, etc).
Q: Can I manually specify filters to include/exclude files from each dependency I declare in bower.json?
If this is not possible, it sounds like i need to resolve "bower install"'s output outside the webapp directory and create a separate (maven/grunt) copy task to create the js lib files structure I want - sounds tedious.
You can use bower-installer which allows you to copy only the files you want by specifying filters to include/exclude files from each dependency in bower.json

Resources