requirejs-common-wrap-middleware

requirejs common wrap middleware

npm install requirejs-common-wrap-middleware
2 downloads in the last week
25 downloads in the last month

RequireJS commonJS wrap middleware

Easiest way to share your modules between server and client side

Usage

As a middleware

var app = express.createServer();
app.use(require('requirejs-common-wrap-middleware').wrapper({
      baseUrl: '/js/',
    basePath: 'static/js/',
    modules: {
        'your_module_url': {
            path: 'path_to_module'
        }
    }
}));

for production at a build script:

require('requirejs-common-wrap-middleware').builder({
      baseUrl: '/js/',
    basePath: 'static/js/',
    modules: {
        'your_module_url': {
            path: 'path_to_module'
        }
    }
});

You can use the same config for wrapper and builder, but wrapper does not use basePath option, in opposite, builder does not use baseUrl option, but do use basePath.

npm loves you