gruntjs – Bootstrap 3.0.1 bower.json打破了grunt-bower-task

Twitter Bootstrap 3.0.1将其bower.json的“main”属性更改为如下所示:

"main": ["./dist/js/bootstrap.js", "./dist/css/bootstrap.css", "./dist/fonts/*"],

他们在3.0.1中添加了“./dist/fonts/*”项 – 它在3.0.0中没有.

现在,当我运行bower:从我的Gruntfile安装时,我收到此错误:

Running "bower:install" (bower) task
bower cached https://github.com/twbs/bootstrap.git#3.0.1
bower validate 3.0.1 against https://github.com/twbs/bootstrap.git#>= 3.0.0
bower cached https://github.com/components/jquery.git#2.0.3
bower validate 2.0.3 against https://github.com/components/jquery.git#>= 2.0.0
bower cached https://github.com/components/jquery.git#2.0.3
bower validate 2.0.3 against https://github.com/components/jquery.git#>= 1.9.0
bower install jquery#2.0.3
bower install bootstrap#3.0.1
>> Installed bower packages
grunt-bower copying bower_components/bootstrap/dist/js/bootstrap.js -> public/bootstrap/bootstrap.js
grunt-bower copying bower_components/bootstrap/dist/css/bootstrap.css -> public/bootstrap/bootstrap.css
/Users/hoytk/git/titanium_ui/node_modules/grunt-bower-task/node_modules/bower/node_modules/tmp/lib/tmp.js:261
throw err;
    ^
Error: ENOENT, no such file or directory 'bower_components/bootstrap/dist/fonts/*'

似乎grunt-bower-task无法处理./dist/fonts/*,但我认为有一些简单的我不知道.这是我的Gruntfile.js:

module.exports = function(grunt) {
    // Project configuration
    grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            bower: {
                    install: {
                            options: {
                                    targetDir: './public',
                                    verbose: true
                            }
                    }
            }
    });

    // Load bower task plugin
    grunt.loadNpmTasks('grunt-bower-task');

    // The default task - install the bower dependencies
    grunt.registerTask('default', ['bower:install']);
}

最佳答案 Bower不支持*在他们的主文件定义中(这是该任务如何知道要复制哪些文件等).

我相信他们在Bootstrap上都知道它,但它仍然是3.0.2中的一个全局.他们还试图让Bower(或许这是特定任务的错误?)来支持全球.

在那之前,没有好的解决方案.更新Bootstrap的bower.json(显式列出每个字体)(注意bower.json可能会在下次更新时被覆盖)或手动复制文件:-(

(注意,如果你走那条路径(隐藏文件),你可能必须在Bootstrap中更改.bower.json)

点赞