Skip to content

Instantly share code, notes, and snippets.

@mereskin-zz
Created April 19, 2013 02:14
Show Gist options
  • Save mereskin-zz/5417634 to your computer and use it in GitHub Desktop.
Save mereskin-zz/5417634 to your computer and use it in GitHub Desktop.
requirejs optimize node app

Given Node.js app with a CJS requires.

app.js

// Depends on underscore
var _ = require('underscore');
var mult = require('./mult');

var app = {
  x: 1,
  y: 2,
  
  multArray: function(arr){ return _.map(arr, mult); }
}

module.exports = app;

I want to optimize app.js into AMD module and instead of inlining underscore substitute it with require('cdn.underscore'). Because in browser environment underscore will already be present with this name and I don't want to include it again.

Can I set up r.js optimizer in a way it will handle this situation?

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