سؤال

I wanted to know if there is any way I can customize how r.js processes the source code of javascript (or other) files during the merging/optimization of a project that uses require.js.

I need to apply some custom transformations, as for example handling some java-like annotations.

I'm looking for something similar to what is possible with browserify using the b.use().

هل كانت مفيدة؟

المحلول

Found the solution. Is it actually possible using the "onBuildWrite" configuration parameter , and specifying a callback that is executed before each module is serialized. Something like:

var config = {
  baseUrl: 'src',
  onBuildWrite: function( name, path, contents ) {
    //Additional processing
    return contents;
  },
  modules: [{ 
    name: 'main' 
  }],
};
requirejs.optimize( config, function(results) {});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top