【问题标题】:Grunt ng-annotate copies complete directoryGrunt ng-annotate 复制完整目录
【发布时间】:2016-08-10 10:50:00
【问题描述】:

我已将 Grunt 配置为使用 ng-annotate。我想要的是注释特定目录中的所有 .js 文件,并在注释完成后将它们复制到新目录。但是,完整的 src 文件夹将复制到新目录。这是我的配置:

 ngAnnotate: {
        options: {
            singleQuotes: true
        },
        dist: {
            files: [{
                expand: true,
                src: ['./src/modules/*.js'],
                dest: './src/min-safe',
                ext: '.annotated.js',
                extDot: 'last'
            }],
        }
    }

这样,我有一个最小安全文件夹,其中包含 src/modules 和带注释的文件。如何直接将带注释的文件复制到 min-safe 中?

【问题讨论】:

    标签: gruntjs annotations minify ng-annotate


    【解决方案1】:

    Grunt 的 srcdest 选项可能会令人困惑,但它们在插件之间是一致的(或者至少应该如此)。 Grunt 文档解释了 how those options can be used 处理文件。

    您的问题是您没有指定cwd 选项,因此所有src 匹配项都针对项目的当前目录(cwd 默认值)。复制src 文件时,包含cwd 和匹配文件之间的目录。

    如果你使用这个配置,它应该做你想做的事:

    ngAnnotate: {
        options: {
            singleQuotes: true
        },
        dist: {
            files: [{
                expand: true,
                cwd: './src/modules',
                src: ['*.js'],
                dest: './src/min-safe',
                ext: '.annotated.js',
                extDot: 'last'
            }]
        }
    }
    

    【讨论】:

    • 谢谢你,我会试试看,如果成功了再告诉你。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-01
    • 2015-09-07
    • 1970-01-01
    相关资源
    最近更新 更多