设置rake-pipeline以与Google App Engine一起使用
所以这就是我正在尝试做的事情。 我正在构建一个ember.js应用程序,在GAE上运行java后端。
我正在使用把手,但我希望它们分成单独的文件,而不是全部粘贴到index.html中。
通过ember.js irc,我和minispade一起打开了rake-pipeline
随着Webfilter和自定义手柄filter,我开始构建资产文件。 我不知道Ruby,或者gem文件等。
因此,我试图找出能够动态编译我的coffeescript / handlebars文件的最佳方法,minispade它们,但在开发模式下保持各个文件可访问,以便我可以调试它们。 令人困难的是,rake管道运行在与GAE不同的端口上。 所以我不确定如何处理这个问题。 在开发期间,我是否将GAE中的索引文件指向9292端口(rakep)中的单个文件,但是在生产模式下是否指向完全连接的版本? 我不确定。
所以我试图在这里做到这一点: https : //gist.github.com/1495740只有一个由’build’标志触发的部分。 甚至不确定这是否有效。
我知道这里有很多混乱。 道歉,就像我说的那样,我甚至不熟悉Ruby的做事方式。
Rake::Pipeline.build
是评估Assetfile
的方法。 您可以想象整个Assetfile
都包含在Rake::Pipeline.build {}
块中; 你不应该在Assetfile
写一个。
文档中的一些filter是假设的,大多数文档都是在有任何filter之前编写的。 不过最近添加了CoffeeScript编译器。
至于你的主要问题,我不确定用当前的rakep
实现做一个干净的方法。 但是, Assetfile
只是Ruby,所以可以将一些应该起作用的东西放在一起。 这是我写你的方式:
require "json" require "rake-pipeline-web-filters" require "rake-pipeline-web-filters/helpers" class HandlebarsFilter < Rake::Pipeline::Filter def initialize(&block) block ||= proc { |input| input.sub(/\.handlebars$/, '.js') } super(&block) end def generate_output(inputs, output) inputs.each do |input| output.write "return Ember.Handlebars.compile(#{input.read.to_json})" end end end # process all js, css and html files in app/assets input "assets" # processed files should be outputted to public output "public" # process all coffee files match "**/*.coffee" do # compile all CoffeeScript files. the output file # for the compilation should be the input name # with the .coffee extension replaced with .js coffee_script # The coffee_script helper is exactly equivalent to: # filter Rake::Pipeline::Web::Filters::CoffeeScriptCompiler end match "**/*.js" do minispade if ENV['RAKEP_ENV'] == "production" concat "application.js" else concat end end match "**/*.handlebars" do filter HandlebarsFilter minispade concat "templates.js" end
if ENV['RAKEP_ENV']
位读取环境变量以决定是否将JS连接到单个文件。
所以现在你可以为连接版本运行RAKEP_ENV="production" rakep build
构建,或者只为开发构建运行RAKEP_ENV="production" rakep build
构建。
由于您不是Ruby人员,因此以下是使用rake管道设置库存OSX环境的最可靠步骤:
第1步:安装bundler
# on OSX, using built-in Ruby $ sudo gem install bundler --pre
第2步:创建Gemfile
# inside your app directory $ bundle init # will create a file named Gemfile in the root
第3步:将rake-pipeline添加到Gemfile
# inside the Gemfile gem "rake-pipeline-web-filters"
第4步:安装你的gem
$ bundle install --binstubs
第5步:设置Assetfile
不过你已经在做了……
第6步:运行Rake :: Pipeline
# to run the preview server $ bin/rakep # to build your assets $ bin/rakep build