javascript - 如何在 Grunt Build 中使用多个复制命令?

标签 javascript gruntjs

我想复制一些文件,运行其他任务,然后再次复制一些文件:

copy:{....},
concat:{...},
copy:{...}

但是,当我运行 grunt build 时出现以下错误:

SyntaxError: Duplicate data property in object literal not allowed in strict mode

当然我明白,我不能在 grunt json 中多次使用相同的属性(即“复制”)。但是我的问题的解决方案是什么?如何在 gruntfile.js 的不同位置进行复制?

非常感谢!

最佳答案

只需将您的复制评论拆分到所需的子任务中:

copy: {
    task1: {
        files: [...]
    }
    task2: {
        files: [...]
    },
    task3: {
        files: [...]
    }
}

然后像这样运行 Grunt:

grunt.registerTask('development', [ 'copy:task1', 'concat', 'copy:task2' ]);

关于javascript - 如何在 Grunt Build 中使用多个复制命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26840988/

相关文章:

javascript - 为什么 Object.prototype.toString.call() 给出的输出与 Object.prototype.toString() 不同?

javascript - 如何在我的函数中停止时间间隔?

HTML 注释导致使用 Grunt-usemin 导出 CSS 文件时出现问题

javascript - 从 AngularJS 中的本地数组加载更多数据

javascript - dijit.form.filteringselect 动态改变选项

gruntjs - Grunt : what is the purpose of cwd?

javascript - Sequelize 与 PostgreSQL 的关系 (generator-sql-fullstack)

gruntjs - 无法使 grunt-contrib-compass 工作

gruntjs - Grunt usemin 任务没有正确更新嵌套的相对路径

javascript - 超时时间好像不能设置超过60s