Concatenate and uglify Node.js files with r.js

54 Views Asked by At

In my backend I use Node.js together with Require.js in this way:

define([
    //Packages
    'express',
    'http'
],
function (
    express,
    http
) {
   //Do something with express and http
});

In my front-end I use r.js to concatenate all the files in one big file and to uglify it. I would like to do the same thing here.

The problem on the backend is that in this case, since NodeJs has it's own module-loader, Node itself is able to find express in the node_modules folder but r.js instead search for express only in the main folder ./express.js and not in /node_modules/express/index.js

How can I tell r.js to look also on the node_modules folders ?

1

There are 1 best solutions below

0
amiramw On

You could try to pass the paths option in your requirejs options in your grunt file. If you define path from your node_modules folder r.js should pick it up.