1

I have an application built in Brunch.io that builds the main framework into app.js, but in my assets folder I have various small coffeescript scripts that need to be compiled individually, and not merged together into one.

Is there a way to compile the CS first and then move it to the public folder like everything else in assets?

I notice that there are some plugins for doing this exact thing with Jade templates (so you can have .jade files in your assets folder). Would this need to be a new plugin?

If there's no obvious way to do it, is there at least a way to define the config file so that it can watch a different folder and compile each .coffee file to it's own .js file, without either joining them all together, or needing to specify each file in the config?

4

1 回答 1

3

由于没有答案,这是我最终这样做的(有点hacky)方式:

我安装了After-Brunch插件并将这两个命令添加到我的配置文件中,这些命令在 Brunch 每次编译后运行:

  plugins:
    afterBrunch: [
      'find public/ -type f -name "*.coffee" -delete'
      'coffee --compile --output public app/assets/'
    ]

所以这只是明确地删除了早午餐移动到 public/ 的 .coffee 文件,然后编译 assets/ 中的所有 .coffee 文件并将它们移动到 public/ 。哈克但它工作正常。

这令人讨厌地感觉很倒退:编译那些已经被早午餐移入 public/ 的 .coffee 文件会感觉更干净(即使只是在我的脑海中),但 Coffee 没有就地转换选项(即替换我所知道的文件),并首先在 public/ 中的文件上运行转换器,然后删除所有 *.coffee 文件不起作用,因为在编译命令完成之前执行的删除命令......但同样,这种区别可能就在我的脑海中——这样做同样有效。

如果有人有更像早午餐的解决方案,那就太好了。

于 2014-01-24T15:40:38.240 回答