【问题标题】:Installing jQuery-Mobile via bower通过 bower 安装 jQuery-Mobile
【发布时间】:2013-07-17 15:48:42
【问题描述】:

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

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

这很乏味,如果我必须为我使用的每个库都这样做,我想我会退回到只下载文件并将它们添加到我的项目中。

那么有没有更优雅的方式通过 bower 依赖来获取那些“最终”文件?

我的bower.json

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

【问题讨论】:

  • bower install jquery-mobile-bower 好像是几个小时前创建的:o
  • 事实上我也是偶然发现的。随意添加这个作为答案。测试成功后我会接受...

标签: javascript html node.js gruntjs bower


【解决方案1】:

是否必须运行 npm/grunt 进程取决于每个作者。对于 jQuery Mobile,可能一些外部用户注册了它而没有注意到它需要运行 Grunt 任务;不幸的是,Bower 允许每个人注册包(这是坏的还是好的?:S)。

另外,可能存在一些 Grunt 任务来安装 bower 依赖项并运行它们的 Grunt 任务;如果没有,创建一个也不会太复杂。

无论如何,您似乎“急于”获取那些最终的编译文件,jquery-mobile-bower 是几个小时前创建并注册到 Bower 的。

bower install jquery-mobile-bower

我们只希望它得到维护和更新。

【讨论】:

    【解决方案2】:

    请注意,有一个官方的 jQuery 移动 Bower 包可用。它可以通过以下方式安装:

    bower install jquery-mobile
    

    可以找到它的 GitHub 端点here

    【讨论】:

    • 这就是最初的问题。
    • @mcepl,我的回答提供了一个替代存储库,这似乎是官方的。谢谢。
    • 最初的问题是质疑为什么使用这个凉亭存储库“jquery-mobile”下载开发文件。他们不想npm install && grunt 他们甚至指定他们在帖子中使用了 jquery-mobile。只是想解释@mcepl 的评论 :) 我对bower install jquery-mobile 有很多麻烦@
    【解决方案3】:

    我不确定我的解决方案是否最佳,但我从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

    【讨论】:

      猜你喜欢
      • 2018-05-26
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多