This plugin provides a Wrapper for http://code.google.com/p/wro4j/
Inspired by wro4j-maven-plugin: http://code.google.com/p/wro4j/source/browse/wro4j-maven-plugin/
- sbt 0.11.3
In your project/plugins.sbt add:
resolvers += Resolver.url("sbt-plugin-snapshots",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots/"))(
Resolver.ivyStylePatterns)
addSbtPlugin("com.bowlingx" %% "xsbt-wro4j-plugin" % "0.1.0-SNAPSHOT")
In your build.sbt add:
import com.bowlingx.sbt.plugins.Wro4jPlugin._
import Wro4jKeys._
// import task settings
seq(wro4jSettings: _*)
// If you use xsbt-web-plugin, this will add compiled files to your war file:
(webappResources in Compile) <+= (targetFolder in generateResources in Compile)
Wro4j is configured through wro.xml and wro.properties file in src/main/webapp/WEB-INF
wro.xml
contains group definitions for file resources (like css, less, js Files).wro.properties
contains pre -and post processor configuration.
The current implementation reads those provider informations (shortcuts) from classes extending com.bowlingx.sbt.plugins.wro4j.Processors
You can easily provide your custom Provider if you override processorProvider in generateResources
e.g.
(processorProvider in generateResources in Compile) := new MyCustomProviderForProcessors
The current build in provider creates the following pre and post processors (will be extended):
- CssUrlRewritingProcessor
- CssImportPreProcessor
- SemicolonAppenderPreProcessor
- LessCssProcessor
- CssDataUriPreProcessor
- CopyrightKeeperProcessorDecorator with JSMinProcessor
- YUICssCompressorProcessor
preProcessors = cssUrlRewriting,cssImport,semicolonAppender,lessCss
postProcessors = yuiCssMin,copyrightMin
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.isdc.ro/wro wro.xsd">
<group name="styles">
<css>/static/styles/base.less</css>
</group>
<group name="scripts">
<js>/static/js/first.js</js>
<js>/static/js/second.js</js>
</group>
</groups>
This plugin depends on package
and will then compile all your defined groups for you.
You also can compile you assets manually if you invoke wro4j
.
All assets are written to target/wro4j/compiled/
by default. If you use xsbt-web-plugin
and package a war
file,
your assets will be available in webapp/compiled/groupName.groupSuffix
http://www.apache.org/licenses/LICENSE-2.0
Any contribution is welcome, just issue a pull-request or bug/feature if you found something :)