Skip to content

Instantly share code, notes, and snippets.

@jish
Created March 28, 2012 16:48
Show Gist options
  • Select an option

  • Save jish/2228129 to your computer and use it in GitHub Desktop.

Select an option

Save jish/2228129 to your computer and use it in GitHub Desktop.
require 'bundler'
Bundler.setup(:assets)
require 'rake-pipeline-web-filters'
RequireFilter = Rake::Pipeline::Web::Filters::NeuterFilter
REQUIRE_REGEX = %r{//= require (.*)}
output 'public'
load_paths = ['app/assets/javascripts', 'vendor/assets/javascripts']
outfiles = ['foo.js', 'application.js']
input load_paths, '*.js' do
outfiles.each do |outfile|
match outfile do
filter RequireFilter, outfile, :require_regexp => REQUIRE_REGEX
end
end
end
@jamesarosen
Copy link

Cool. We'll probably have to subclass NeuterFilter to turn //= require_tree into a Dir.glob.

@shajith
Copy link

shajith commented Mar 28, 2012

Ah, I passed over NeuterFilter when I was looking rake-pipeline yesterday. Totally wasn't clear (from the name, at least) how I can use it for dependencies. Ended up specifying a manually ordered list to concat.

It does feel a little hacky though - how does this, for instance resolve deps in a manner that doesn't include the same files twice? (might already do that, i'm just curious)

@jamesarosen
Copy link

@wycats suggests using Rails.application.assets.paths in the Assetfile to get the benefits of Rails's engine awesomeness.

@shajith: yes, NeuterFilter adds dependencies to an ordered set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment