Javascript 用Cakefile编译CoffeeScript
目前我使用它将其编译为一个文件:Javascript 用Cakefile编译CoffeeScript,javascript,compiler-construction,coffeescript,Javascript,Compiler Construction,Coffeescript,目前我使用它将其编译为一个文件: task 'CurrentVillage', 'Build Current Vilage', -> remaining = appFiles.length appContents = new Array remaining for file, index in appFiles then do (file, index) -> fs.readFile "media/coffee/#{file}.coffee", 'utf8',
task 'CurrentVillage', 'Build Current Vilage', ->
remaining = appFiles.length
appContents = new Array remaining
for file, index in appFiles then do (file, index) ->
fs.readFile "media/coffee/#{file}.coffee", 'utf8', (err, fileContents) ->
throw err if err
appContents[index] = fileContents
process() if --remaining is 0
process = ->
fs.writeFile 'media/coffee/frontend/VillageCanvas.coffee', appContents.join('\n\n'), 'utf8', (err) ->
throw err if err
我无法将其直接编译为javascript:S您需要在
Cakefile
中定义任务,然后调用该Cakefile。将Cakefile
放入同一目录后,从coffeescript文件所在的目录在终端中运行cakebuild
。这里有一个简单的Cakefile模板。它已经具有编写的构建功能,如下所述:
您需要在
Cakefile
中定义任务,然后调用该Cakefile。将Cakefile
放入同一目录后,从coffeescript文件所在的目录在终端中运行cakebuild
。这里有一个简单的Cakefile模板。它已经具有编写的构建功能,如下所述:
康纳说的话(得到了我的赞成票)
如果您想使用“AtthementStandardJavaScriptBuildTool”;-)的话,也可以使用 康纳说的话(得到了我的支持)
如果您想使用“AtthementStandardJavaScriptBuildTool”;-)的话,也可以使用 这个问题只编译src中的文件。我想编译组合代码。我不想保存组合的咖啡文件。请将
Cakefile
放在目录的根目录中,然后从那里运行cake build
。问题是,这只编译src中的文件。我想编译组合代码。我不想保存组合的咖啡文件。请将Cakefile
放在目录的根目录中,然后从那里运行cake build
。
build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-c', '-b', '-o', 'lib', 'src']
options.unshift '-w' if watch
launch 'coffee', options, callback