Giter Club home page Giter Club logo

asset-pipeline's Introduction

asset-pipeline

This project aims to be a simple asset pipeline for JSP applications. It was inspired by the likes of BakeHouse. Check out the demo project or see the quickstart.

QuickStart

  1. Add my GitHub Maven Repository & the asset-pipeline dependency to your pom.xml. This example uses the Google Closure adapter (which is the only implementation available now)
    <repositories>
		<repository>
			<id>ntier-repo</id>
			<url>https://github.com/dwelch2344/maven-repo/raw/master/releases</url>
		</repository>
		<repository>
			<id>ntier-snapshot-repo</id>
			<url>https://github.com/dwelch2344/maven-repo/raw/master/snapshots</url>
			<snapshots>
			</snapshots>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>co.ntier.web</groupId>
			<artifactId>asset-pipeline-closure</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
		<!-- Your dependencies HERE! -->
	</dependencies>
  1. Configure your ServletContext as appropriate. The following example uses Spring's JavaConfig to hook things up correctly
@Configuration
@EnableWebMvc
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class WebConfig extends WebMvcConfigurerAdapter {
	
	@Inject ServletContext ctx;
	
	@PostConstruct
	public void onSetup(){
		// comment the next line out to prevent minification
		ctx.setAttribute(PipelineConstants.IS_PRODUCTION_KEY, true);
		ctx.setAttribute(PipelineConstants.RESOURCE_COMPILER_KEY, new ClosureResourceCompiler());
	}
	    
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
	    // add the generated sources folder for serving static content
	    registry.addResourceHandler("/gen/**").addResourceLocations("/gen/");
	}
}

NOTE: The /gen/ mapping should correspond to the prefix used in the next step...

  1. Declare your resources in your JSP
<%@ taglib prefix="pipeline" uri="http://ntier.co/pipeline" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  
  <!-- Generated code will be here -->
  <%-- Note that the "/gen" prefix corresponds to the ResourceHandler mapping in step 2 --%>
  <pipeline:scripts ref="/gen/app.js">
		<pipeline:script src="/resources/app1.js"/>
		<pipeline:script src="/resources/app2.js"/>
		<%-- <pipeline:script src="/resources/app3.js"/> --%>
	</pipeline:scripts>
</head>
  1. Enjoy!

When developing, just comment out the IS_PRODUCTION_KEY line from the configuration file and you'll get the raw resources.

asset-pipeline's People

Contributors

dwelch2344 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.