【问题标题】:Simple grunt copy task not working简单的 grunt 复制任务不起作用
【发布时间】:2016-04-04 06:03:59
【问题描述】:

有人可以帮助我并告诉我我在这里做错了什么。我有以下 grunt 任务,我想将 css 文件从构建目录移动到项目的根目录。

module.exports = {
    copy: {
        main: {
            files: [{
                expand: true,
                cwd: "build/css/",
                src: "style.css",
                dest: "../"
            }]
        },
    },
}

当我运行 grunt copy -v 时,它是这样说的:

$ grunt copy -v
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Running tasks: copy

Running "copy" task

Running "copy:copy" (copy) task
Verifying property copy.copy exists in config...OK
File: [no files]
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false


Done, without errors.

【问题讨论】:

  • 我认为 files 属性不应该有 [] 括号,也许可以尝试运行 grunt copy:main
  • 当我尝试 copy:main 时,我得到以下信息:运行“copy:main”(复制)任务验证属性 copy.main 存在于配置中...错误 >> 无法处理任务。警告:缺少必需的配置属性“copy.main”。使用 --force 继续。由于警告而中止。

标签: gruntjs grunt-contrib-copy


【解决方案1】:

别着急,解决了。晚上太晚了... :(

任务在文件名下运行,因此删除了copy,现在它可以工作了。

module.exports = {
    main: {
        files: [{
            expand: true,
            cwd: "build/css/",
            src: "style.css",
            dest: "../"
        }]
    },
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多