通过bower安装jQuery-Mobile

在我的项目中,我想通过凉亭使用jquery-mobile。

在我可以使用它之前,我必须在bower_components/jquery-mobile之后运行npm installgrunt然后才能使用缩小的.js.css文件。

这是非常乏味的,如果我不得不为每个使用的库都做这个,我想我会后退到下载文件并将它们添加到我的项目中。

那么有没有更优雅的方式通过鲍尔依赖关系到达这些“最终”文件?

我的bower.json

 "dependencies": { ... "jquery-mobile": "latest", } 

必须运行npm / grunt进程(或不运行)的事实取决于每个作者。 在jQuery Mobile的情况下,可能有些外部用户已经注册了它,而没有注意到它需要运行Grunt任务; 鲍尔不幸的是允许每个人都注册套餐(是坏的还是好的?:S)。

另外, 可能还存在一些Grunt任务来安装鲍尔依赖关系并运行他们的Grunt任务; 如果没有,创build一个并不复杂。

无论如何,因为你似乎对这些最终的编译文件“匆忙”, jquery-mobile-bower已经在几个小时前被创build并注册到了Bower中。

 bower install jquery-mobile-bower 

让我们只希望这个得到保持和最新。

只是你知道,有一个官方的jQuery移动Bower包可用。 它可以通过以下方式安装:

 bower install jquery-mobile 

它的GitHub端点可以在这里find。

我不确定我的解决scheme是否是最佳的,但我从bower.json删除了jquery-mobile ,并使用grunt-contrib-cleangrunt-gitgrunt-run插件来安装和构buildGrunt 。 我想出了这个,因为我不想使用jquery-mobile-bower ,因为这是一个非官方的回购。

下面是一个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' ]); }; 

更多细节可以在这里findhttps://github.com/jquery/jquery-mobile/issues/7554