为具有多个点的文件配置Grunt文件名匹配 [英] Configure Grunt File Name Matching for Files with Multiple Dots

查看:82
本文介绍了为具有多个点的文件配置Grunt文件名匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用咕噜声,并且喜欢它。
我遇到了一个似乎可能很常见的问题。
在这里。我有文件命名,以便点后的单词是类似的东西。例如:

I just started using grunt, and love it. I keep running into an issue that seems like it might be pretty common. Here it is. I have files named so that words after a dot are something like classes. eg:

layout.coffee
layout.blog.coffee
layout.site.coffee

我的grunt任务被配置为观察这些文件并将它们翻译为js,如下所示:

My grunt task is configured to watch these files and translate them to js like this:

coffee:
  dev:
    files: [
      expand: true
      cwd: "<%= yeoman.app %>"
      src: ["**/*.coffee"]
      dest: "<%= yeoman.dev %>"
      ext: ".js"
    ]

我想,是使用 ext 使所有三个.coffee文件的目标文件成为目标文件 layout.js ,这不是

The problem, I think, is that using ext makes the target for all three .coffee files the destination file layout.js, which isn't the intention.

是否有一个很好的方法来配置多点文件名的grunt文件映射?

Is there a nice way to configure grunt file mapping for filenames with multiple dots?

正确现在我必须改变我的命名约定来使用 - 而不是,这是一个拖拽:(

Right now I have to change my naming convention to use - instead of ., which is a drag :(

推荐答案

查看配置任务

而不是指定 ext ,你可以指定 rename 这是一个让你创建你自己的映射文件名的函数。

Instead of specifying ext, you can specify rename which is a function that lets you create your own mapping for the file names.

你遇到的问题是作为 issue ,而咕噜声人的回答是,文件的扩展名应该是第一个。之后的所有内容,而不是最后一个。

The problem you are running into was brought up as an issue on github and the answer from the grunt folks was that the "extension" of a file should be everything after the first "." instead of the last.

希望对你有所帮助!

这篇关于为具有多个点的文件配置Grunt文件名匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆