Is it possible to have a Play 2.3 app concat/optimize JS (using sbt-rjs) that's included in my app via WebJars?
To give a concrete example: I'm trying to create a core.js module which contains all my 3rd party libraries concatenated and minified in a single file which can then be specified as a dependency for other AMD modules.
It would be great to include these libraries via WebJars instead of downloading the source "manually".
Here's a snippet from my build.sbt file where I'm specifying my webjar dependencies:
// Webjars
libraryDependencies ++= Seq(
"org.webjars" % "requirejs" % "2.1.15",
"org.webjars" % "underscorejs" % "1.7.0",
"org.webjars" % "jquery" % "1.11.1",
"org.webjars" % "bootstrap" % "3.3.1" exclude("org.webjars", "jquery"),
"org.webjars" % "angularjs" % "1.3.4-1" exclude("org.webjars", "jquery")
)
Here's my requireJS build config
requirejs.config({
baseUrl: '/assets/javascripts',
shim: {
'jsRoutes': {
deps: [],
exports: 'jsRoutes'
},
'angular': {
deps: ['jquery'],
exports: 'angular'
},
'underscore': {
exports: '_'
},
'angularRoute': ['angular'],
'angularCookies': ['angular'],
'bootstrap': ['jquery']
},
paths: {
'requirejs': '../lib/requirejs/require',
'jquery': '../lib/jquery/jquery',
'underscore': '../lib/underscorejs/underscore',
'angular': '../lib/angularjs/angular',
'angularRoute': '../lib/angularjs/angular-route',
'angularCookies': '../lib/angularjs/angular-cookies',
'bootstrap': '../lib/bootstrap/js/bootstrap',
'jsRoutes': '/jsroutes',
'core': './core'
},
modules: [
{
name: 'core'
}
]
});
And finally, here's my core.js module:
define(['angular', 'angularRoute', 'underscore', 'bootstrap'], function() {
// core dependencies are loaded...
});
After running activator clean stage
from the command line I was hoping the built core.js file would include all my specified dependencies concatenated and minified into a single file, but it doesn't include any of them. If I specify a non-WebJar file as a dependency for core.js, it does optimize that correctly.
Is what I'm trying to do possible? I've been googling quite a bit and haven't been able to find a clear answer either way.
Thanks!
sbt-rjs
right now. You might want to file an issue: github.com/sbt/sbt-rjs/issues – James Ward