It turned out that RequireJS optimization support does not apply to all Webjars, but is limited to classic Webjars. 
Even then, the webjar build file must be included with the regular module for rjs to work. 
If you look at classic webjar jQuery, for example, you will see that a special instruction for building webjar is included. Take a look at this file for your information. 
Once you define a webjar that is RequJS ready, you can let sbt-rjs do this. Here is my setup for reference:
'use strict'; requirejs.config({ paths:{ 'jquery': ['../lib/jquery/jquery'], 'react': ['../lib/react/react'], 'bootstrap': ['../lib/bootstrap/js/bootstrap'], 'react-bootstrap': ['../lib/react-bootstrap/react-bootstrap'] }, shim: { 'bootstrap': { deps: ['jquery'] }, 'react-bootstrap': { deps: ['react'] } } });
Do not forget to have square brackets, otherwise CDN replacement will not happen.
For scripts that are not required, you should not have square brackets when declaring paths . Otherwise, rjs will refuse to build with the error path fallback not supported . Of course, you will not get the benefits of CDN. Just note that optimizing RequireJS css too. But it is limited only to embedding css, as regular Requirejs does.
source share