Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/debugging/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs 将bower依赖项读入grunt文件列表_Gruntjs_Bower - Fatal编程技术网

Gruntjs 将bower依赖项读入grunt文件列表

Gruntjs 将bower依赖项读入grunt文件列表,gruntjs,bower,Gruntjs,Bower,我正在使用grunt,我想在创建生产发行版时复制我的bower依赖项 这些依赖项已存在于./components中 我生成了一个包含index.html的生产目录,只想从bower.json文件中复制依赖项 我认为这就像从DEP生成一个列表一样简单: prodComponents = Object.keys(grunt.file.readJSON('./bower.json').dependencies) (从简单的console.log(prodComponents)生成) 然后只需复制匹配

我正在使用grunt,我想在创建生产发行版时复制我的bower依赖项

这些依赖项已存在于./components中

我生成了一个包含index.html的生产目录,只想从bower.json文件中复制依赖项

我认为这就像从DEP生成一个列表一样简单:

prodComponents = Object.keys(grunt.file.readJSON('./bower.json').dependencies)
(从简单的console.log(prodComponents)生成)

然后只需复制匹配的文件:

    copy:
        deps:
            files: [
                expand: true
                cwd: './components'
                src: ['./<%= prodComponents %>/*']
                dest: './dev/components'
            ]
如果我删除./则它会失败,原因是:

Warning: Unable to read "components/Applications" file (Error code: ENOENT). Use --force to continue.
我忍不住觉得我要么太聪明了,要么就快成功了

我对文件规范的规范有什么错


谢谢

我想你很接近了。我会用应用于
prodComponents
的全局模式保存目录:

prodComponents = Object.keys(grunt.file.readJSON('./bower.json').dependencies).map(
    function(prodComponent) {
        return prodComponent + "/**/*";
    }
);
因此,
prodComponents
将包含:

["requirejs/**/*",
 "requirejs-text/**/*",
 "jquery/**/*",
 "underscore-amd/**/*",
 "backbone-amd/**/*",
 "backbone.wreqr/**/*",
 "backbone.babysitter/**/*",
 "marionette/**/*" ]
复制
配置将是:

copy:
    deps:
        files: [
            expand: true
            cwd: 'components'
            src: '<%= prodComponents %>'
            dest: 'dev/components'
        ]
复制:
副署长:
档案:[
扩展:正确
cwd:‘组件’
src:'
目标:“开发/组件”
]

请注意,要想以这种方式在模板中使用
prodComponents
,需要在模板中设置它。

不像我最初设想的那样简洁,但效果不错。感谢参考:prodComponent+“/*”应该是prodComponent+“/***”以捕获子目录。
["requirejs/**/*",
 "requirejs-text/**/*",
 "jquery/**/*",
 "underscore-amd/**/*",
 "backbone-amd/**/*",
 "backbone.wreqr/**/*",
 "backbone.babysitter/**/*",
 "marionette/**/*" ]
copy:
    deps:
        files: [
            expand: true
            cwd: 'components'
            src: '<%= prodComponents %>'
            dest: 'dev/components'
        ]