2013-07-18 182 views
13

在我的項目中,我想通過涼亭使用jquery-mobile。通過涼亭安裝jQuery-Mobile

之前,我可以用它我要運行npm installgrunt隨後的bower_components/jquery-mobile內部之前,我可以使用精縮.js.css文件。

這是非常乏味的,如果我必須爲每個使用的庫執行此操作,我想我會後退到只下載文件並將它們添加到我的項目中。

那麼有沒有更優雅的方式通過鮑爾依賴關係到達這些「最終」文件?

bower.json

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

'涼亭安裝jQuery的移動bower'好像它已經創造了幾個小時前:○ – gustavohenke

+0

其實我也偶然發現了這一點。隨意添加這個答案。當我成功測試它時,我會接受它... – Besi

回答

19

不必運行NPM /咕嚕處理(或不)的事實是由每個作者。在jQuery Mobile的情況下,可能有些外部用戶已經註冊了它,但沒有注意到它需要運行Grunt任務;不幸的是鮑爾允許每個人都註冊套餐(是壞的還是好的?:S)。

此外,可能存在一些Grunt任務來安裝鮑爾依賴關係並運行其Grunt任務;如果沒有,創建一個並不複雜。

無論如何,因爲看起來您對這些最終的編譯文件「很着急」,有幾個小時前已創建並註冊到Bower的jquery-mobile-bower

bower install jquery-mobile-bower 

讓我們只希望這個得到保持和最新。

7

只要你知道,就有官方的jQuery移動Bower包可用。

bower install jquery-mobile 

其GitHub的端點,可以發現here:它可以通過安裝。

+2

這就是原始問題。 – mcepl

+0

@mcepl,我的答案提供了一個替代版本庫,它似乎是官方版本。謝謝。 – Drew

+1

最初的問題是質疑爲什麼開發文件是用這個涼亭庫「jquery-mobile」下載的。他們不想'npm install && grunt'他們甚至指定他們在他們的帖子中使用了jquery-mobile。 只是想解釋@ mcepl的評論:)我有一大堆麻煩與'bower安裝jquery-mobile' –

0

我不知道如果我的解決方案是最佳的,但我從bower.json刪除jquery-mobile,我安裝和使用Grunt構建它,使用grunt-contrib-cleangrunt-gitgrunt-run插件。我想出了這個,因爲我不想使用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' 
    ]); 
}; 

更多細節可以在這裏找到https://github.com/jquery/jquery-mobile/issues/7554