Include Require.JS (r.js build) in the Middleman build

I work with Middleman to develop, test, and create my HAML and SASS projects.

Now I also like working with require.js. Is there any way to integrate the R.js assembly into the Middleman assembly?

Have you encountered him? How do you handle require.js with a reseller?

+4
source share
2 answers

As for just "run r.js", it's pretty simple:

  • Save r.js in the root of the project.
  • Define the user extension (config.rb) that executes the r.js command 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 the user extension (config.rb):

     configure :build do … activate :requirejs end 
+5
source

r.js can be used with node via the command line, as an intermediary. I don’t know how exactly you use the intermediary, but including another command in your workflow should not be a problem. You can find instructions for using r.js from the command line here .

+3
source

Source: https://habr.com/ru/post/1447888/


All Articles