Setting Up Rake-Pipeline for Use with Handlebars Alongside Google App Engine

How do you customize the identifier used by MinispadeFilter in rake-pipeline

The MinispadeFilter is pretty dumb about generating module identifiers by default. It just names them after the path of the input files. You're seeing the tmp dirs in there from handlebars and coffeescript because the minispade filter is getting the module id from the place where the pipeline turns them into javascript.
The filter takes a :module_id_generator option which allows you to customize the generation of module ids. If you're not familiar with Ruby, this may be a little heavy for you, so bear with me. The module_id_generator option takes a Ruby proc, which is like an anonymous function in JS. The filter then takes this proc that you pass in and executes it for each input file, passing your proc a FileWrapper object representing the input file, and your proc should return a string that will be used as the module id for that file.

Here's a match block from one of my projects:

match "**/*.js" do
minispade :module_id_generator => proc { |input| input.path.sub(/lib\//, 'timelog/').sub(/\.js$/, '') }
concat "js/app.js"
end

The :module_id_generator is a proc which takes a FileWrapper named input and turns it into the module id I want. The input file's path is available as the path method on input. In this case, my JS files are in a lib/ directory, so I use Ruby's sub method to replace the beginning lib/ part of the path with timelog (the name of the project) then again to remove the .js extension. So a js file named lib/models.js would get a module id of timelog/models.

Proxy for ajax calls using rake-pipeline-web-filters

You can't configure the proxy directly in your Assetfile. You'll have to create a config.ru file and use the rackup command to launch the server.

Here's an example Assetfile:

input "app"
output "public"

And config.ru:

require 'rake-pipeline'
require 'rake-pipeline/middleware'
require "rack/streaming_proxy" # Don't forget to install the rack-streaming-proxy gem.

use Rack::StreamingProxy do |request|
# Insert your own logic here
if request.path.start_with?("/api")
"http://localhost#{request.path.sub("/api", "")}"
end
end

use Rake::Pipeline::Middleware, 'Assetfile' # This is the path to your Assetfile
run Rack::Directory.new('public') # This should match whatever your Assetfile's output directory is

You'll have to install the rack and rack-streaming-proxy gems.

How to write modular Ember.js apps

BPM in it's current form is no longer supported by the core team, but is community supported. The only build tools they are officially providing support for is rake-pipeline. However, BPM does still work and it works well (I still use it with my projects). For info on how to use it see this: https://github.com/ud3323/bpm/wiki/Using-BPM-with-Ember. You may want to use my fork of bpm too. I've merged in Joe West's support for a proxy middleware.

There is also community build tools for node.js called ember-runner which looks promising as well.

As for using rake-pipeline. Look at the AssetFile on the emberjs projects to see how must be configured using rake-pipeline and rake-pipeline-web-filters. Also, take a look at the answers to this question on StackOverflow (especially Yehuda's). You may also find this gist helpful as well.



Related Topics



Leave a reply



Submit