In my project I would like to use jquery-mobile via bower.
Before I can use it I have to run npm install
and grunt
subsequently inside of bower_components/jquery-mobile
before I can use the minified .js
and .css
files.
This is quite tedious and if I had to do this for every library that I use, I guess I would fallback to just downlading the files and add them to my project.
So is there a more elegant way to get to those "final" files via bower dependency?
My bower.json
"dependencies": {
...
"jquery-mobile": "latest",
}
In my project I would like to use jquery-mobile via bower.
Before I can use it I have to run npm install
and grunt
subsequently inside of bower_components/jquery-mobile
before I can use the minified .js
and .css
files.
This is quite tedious and if I had to do this for every library that I use, I guess I would fallback to just downlading the files and add them to my project.
So is there a more elegant way to get to those "final" files via bower dependency?
My bower.json
"dependencies": {
...
"jquery-mobile": "latest",
}
Share
Improve this question
edited Jul 18, 2013 at 16:04
Kara
6,22616 gold badges53 silver badges58 bronze badges
asked Jul 18, 2013 at 15:30
BesiBesi
22.9k24 gold badges132 silver badges229 bronze badges
2
|
3 Answers
Reset to default 19The fact of having to run npm/grunt process (or not) is up to each author. In the case of jQuery Mobile, probably some external user has registered it without noticing that it needs to run Grunt tasks; Bower unfortunately allows everyone to register packages (is that bad or good? :S).
Also, there may exist some Grunt task to install bower dependencies and run their Grunt tasks aswell; if there aren't, it's not too complicated to create one.
Anyway, as it seems that you're in a "hurry" for those final, compiled files, there is jquery-mobile-bower, which has been created and registered into Bower a few hours ago.
bower install jquery-mobile-bower
Let's just hope that this gets maintained and up-to-date.
Just so you're aware, there is an official jQuery mobile Bower package available. It can be installed via:
bower install jquery-mobile
Its GitHub endpoint can be found here.
I'm not sure if my solution is optimal, but I removed jquery-mobile
from bower.json
and I'm installing and building it with Grunt
, using grunt-contrib-clean
, grunt-git
and grunt-run
plugins. I came up with this, because I don't want to use jquery-mobile-bower
, because it's an unofficial repo.
Here's an example Gruntfile.js
:
module.exports = function (grunt) {
grunt.initConfig({
clean: {
jquerymobile: 'bower_components/jquery-mobile'
},
gitclone: {
jquerymobile: {
options: {
repository: 'https://github.com/jquery/jquery-mobile.git',
branch: 'master',
directory: 'bower_components/jquery-mobile'
}
}
},
run: {
options: {
cwd: "bower_components/jquery-mobile"
},
jquerymobile_npm_install: {
cmd: "npm",
args: [
'install'
]
},
jquerymobile_grunt: {
cmd: "grunt"
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-git');
grunt.loadNpmTasks('grunt-run');
grunt.registerTask('default', [
'clean',
'gitclone',
'run'
]);
};
More details can be found here https://github.com/jquery/jquery-mobile/issues/7554
bower install jquery-mobile-bower
seems like it has been created a few hours ago :o – gustavohenke Commented Jul 18, 2013 at 16:16