Reputation: 31249
I work with Middleman to develop, test and build my HAML & SASS Projects.
Now I also like to work with require.js. Is there any way i could integrate the R.js build into the Middleman build?
Did you make any experience with it? How do you handle require.js in middleman?
Upvotes: 4
Views: 1327
Reputation: 1014
As far as just "running r.js" is concerned, it's pretty straightforward:
Define a custom extension (config.rb) which executes r.js after the build:
module RequireJS
class << self
def registered(app)
app.after_build do |builder|
exec('node r.js -o build/javascripts/app.build.js');
end
end
alias :included :registered
end
end
::Middleman::Extensions.register(:requirejs, RequireJS)
Activate custom extension (config.rb):
configure :build do
…
activate :requirejs
end
Upvotes: 5
Reputation: 606
r.js
can be used with node
via the command line, just like middleman. I don't know how exactly you use middleman, but incorporating another command in your workflow shouldn't be a problem. You can find instructions on how to use r.js
from the command line here.
Upvotes: 3