Domanda

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?

È stato utile?

Soluzione

As far as just "running r.js" is concerned, it's pretty straightforward:

  1. Save r.js into the project's root.
  2. 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)
    
  3. Activate custom extension (config.rb):

    configure :build do
        …
        activate :requirejs
    end
    

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top