Overriding WebJar assets in Play 2.x

2019-07-01 23:24发布

问题:

Just wonder, if there is a way to override some assets, precisely JS and LESS files, in a WebJars asset with the ones located in the app/assets/ directory.

Say, I have a bootstrap 3.1.1 webjar installed, so how do I use my own variables.less file for example? Suppose simply putting it in the stylesheets folder would not work.

For LESS, maybe it's possible to import them from within my assets, but what about the others?

回答1:

The conf/routes file is priority ordered. So if you want to override a route just put it higher in the list. For instance:

GET     /webjars/bootstrap/3.1.1/less/variables.less   controllers.Assets.at(path="/public", "my-bootstrap/variables.less")
GET     /webjars/*file                                 controllers.WebJarAssets.at(file)