在我的项目中,我想通过bower使用jquery-mobile。
在使用它之前,我必须随后在bower_components/jquery-mobile中运行npm install和grunt,然后才能使用缩小的.js和.css文件。
这相当乏味,如果我必须为我使用的每个库都这样做,我猜我会退回到只是下载文件并将它们添加到我的项目中。
那么,有没有一种更优雅的方式来通过bower依赖来获取这些“最终”文件呢?
我的bower.json
"dependencies": {
...
"jquery-mobile": "latest",
}发布于 2013-07-19 00:25:57
必须运行npm/grunt进程(或不运行)取决于每个作者。在Bower的情况下,可能有一些外部用户注册了它,而没有注意到它需要运行jQuery任务;不幸的是,它允许每个人注册包(这是好还是坏?:S)。
此外,可能存在一些Grunt任务来安装bower依赖项并运行它们的Grunt任务;如果没有,创建一个也不会太复杂。
不管怎样,看起来你对那些最终的编译文件很“着急”,这里有jquery-mobile-bower,它几个小时前已经被创建并注册到Bower了。
bower install jquery-mobile-bower让我们只希望它得到维护和更新。
发布于 2013-12-24 19:41:49
发布于 2015-06-27 11:22:36
我不确定我的解决方案是否是最优的,但我从bower.json上删除了jquery-mobile,我正在使用Grunt安装和构建它,使用grunt-contrib-clean、grunt-git和grunt-run插件。我想出了这个,因为我不想使用jquery-mobile-bower,因为它是一个非官方的repo。
下面是一个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
https://stackoverflow.com/questions/17727787
复制相似问题