View on GitHub

Bakehouse

Streamlines web pre-processors for Spring resources

Download this project as a .zip file Download this project as a tar.gz file

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:

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:

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:

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.