Bakehouse - cooks up your HTML resources for you.
Bakehouse is a framework for moving pre-processing of web artifacts to the server.
In a typical web project these days, you're likely to have a bunch of tasks that run on your artifacts.
Eg:
- Less for your CSS
- Concatenate and minify your Javascript
- Maybe even use some Typescript or CoffeeScript, which needs to be compiled
However, the type of processing you want to apply often varies between Production and Development environments. (Eg., non-minified code in dev, serve from a CDN in prod).
Bakehouse uses Spring's @Configuration @Profile's to allow you to specify different deployment configs at runtime.
For example:
<%@ taglib prefix="bakehouse" uri="http://www.mangofactory.com/bakehouse" %>
<head>
<bakehouse:resource src="angular.js" cdn="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"/>
<bakehouse:resources configuration="javascript" type="text/javascript">
<bakehouse:resource src="file1.js"/>
<bakehouse:resource src="file2.js"/>
</bakehouse:resources>
<bakehouse:resources configuration="typescript" type="text/javascript">
<bakehouse:resource src="typescript.ts"/>
</bakehouse:resources>
</head>
With our resources wrapped in <bakehouse:... /> tags, we can define multiple configurations depending on the environment we're running in.
For example -- in production:
@Configuration
@Profile("production")
public class ExampleBakehouseConfig implements BakehouseConfigProvider {
@Override @Bean
public BakehouseConfig build(BakehouseConfigBuilder builder) {
return builder
.process("javascript").serveAsSingleFile("AppCode.js")
.process("typescript").with(new TypescriptProcessor("TypescriptCode.js"))
.serveResourcesFromCdn()
.build();
}
}
This specifies:
- Process the
javascriptgroup, concatenating into a single file, calledAppCode.js - Process the
typescriptgroup, compiling the typescript into a single file calledTypescriptCode.js - Download any resources with
cdnaddresses from their relative cdn's (eg., theangularjsresource)
Alternatively, in Dev ---
@Configuration
@Profile("development")
public class ExampleBakehouseConfig implements BakehouseConfigProvider {
@Override @Bean
public BakehouseConfig build(BakehouseConfigBuilder builder) {
return builder
.process("typescript").with(new TypescriptProcessor("TypescriptCode.js"))
.build();
}
}
Here:
-
javascriptresources aren't processed, so will be served 'as-is` - Process the
typescriptgroup, compiling the typescript into a single file calledTypescriptCode.js - CDN resources are ignored, so we'll be serving the local non-minified versions.
Project state
This is a POC project. You're welcome to grab the code and play around with it (the above examples all work), but I'm not committed to actively working on the project unless there's demand.
Register your interest in seeing this get expanded by either starring the project or leave a comment showing you're interested.
Alternatively, have a play, raise some issues, and submit some pull requests with enhancements.