fizzed-play-module-sprockets

PlayFramework 2.x module to create a Ruby-on-Rails inspired asset pipeline (optimize, bundle, and/or fingerprint assets such as CSS, JavaScript, and more)

License

License

GroupId

GroupId

com.fizzed
ArtifactId

ArtifactId

fizzed-play-module-sprockets_2.11
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

fizzed-play-module-sprockets
PlayFramework 2.x module to create a Ruby-on-Rails inspired asset pipeline (optimize, bundle, and/or fingerprint assets such as CSS, JavaScript, and more)
Project Organization

Project Organization

Fizzed, Inc.
Source Code Management

Source Code Management

https://github.com/fizzed/play-module-sprockets

Download fizzed-play-module-sprockets_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.fizzed/fizzed-play-module-sprockets_2.11/ -->
<dependency>
    <groupId>com.fizzed</groupId>
    <artifactId>fizzed-play-module-sprockets_2.11</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.fizzed/fizzed-play-module-sprockets_2.11/
implementation 'com.fizzed:fizzed-play-module-sprockets_2.11:1.2.0'
// https://jarcasting.com/artifacts/com.fizzed/fizzed-play-module-sprockets_2.11/
implementation ("com.fizzed:fizzed-play-module-sprockets_2.11:1.2.0")
'com.fizzed:fizzed-play-module-sprockets_2.11:jar:1.2.0'
<dependency org="com.fizzed" name="fizzed-play-module-sprockets_2.11" rev="1.2.0">
  <artifact name="fizzed-play-module-sprockets_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.fizzed', module='fizzed-play-module-sprockets_2.11', version='1.2.0')
)
libraryDependencies += "com.fizzed" % "fizzed-play-module-sprockets_2.11" % "1.2.0"
[com.fizzed/fizzed-play-module-sprockets_2.11 "1.2.0"]

Dependencies

compile (9)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.2
com.typesafe.play : twirl-api_2.11 jar 1.0.2
com.typesafe.play : play_2.11 jar 2.3.7
com.typesafe.play : play-java_2.11 jar 2.3.7
com.typesafe.play : play-java-jdbc_2.11 jar 2.3.7
com.typesafe.play : play-java-ebean_2.11 jar 2.3.7
com.typesafe.play : play-cache_2.11 jar 2.3.7
com.typesafe.play : play-java-ws_2.11 jar 2.3.7
com.yahoo.platform.yui : yuicompressor jar 2.4.7

test (1)

Group / Artifact Type Version
com.typesafe.play : play-test_2.11 jar 2.3.7

Project Modules

There are no modules declared in this project.

Sprockets for PlayFramework

Overview

Play Framework 2.x module that provides an asset pipeline. Pipeline will optimize, bundle, and/or fingerprint assets such CSS, JavaScript, and more. Inspired by Ruby on Rails asset pipeline.

In development mode, optimization can be disabled and normal HTML tags will be produced which skips bundling, optimization, or minification. In production mode, optimization will occur at runtime the first time a user connects.

Compatibility matrix

PlayFramework version Module version
2.3.x 1.2.0
2.2.x 1.1.0
2.1.x 1.0.0

Usage

This module is published to Maven Central. You will need to include the module in your dependencies list, in build.sbt or Build.scala file:

build.sbt

libraryDependencies ++= Seq(
  "com.fizzed" %% "fizzed-play-module-sprockets" % "1.2.0"
)

Build.scala

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "sample"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    javaCore,
    javaJdbc,
    javaEbean,
    "com.fizzed" %% "fizzed-play-module-sprockets" % "1.2.0"
  )
  
  ...
}

Configuration

conf/application.conf

Add the following section:

mfz-sprockets {
  # true by default in dev, false by default in prod
  #info-enabled = true

  # false by default in either dev or prod
  #debug-enabled = false

  # by default true in prod, false in dev; if set then forced regardless of prod vs. dev
  #optimize-assets = true

  # by default true in prod, false in dev; if set then forced regardless of prod vs. dev
  #cache-control-assets = false
 
  assets {
    # must exist for OptimizedAssets to work
    optimized-assets {
      uri = "/assets/o"
      dirs = "target/optimized-assets"
      fallback = true
    }
  }
}

Within templates

See samples project for full example.

To optionally bundle, minify, and fingerprint stylesheets:

@com.fizzed.play.sprockets.OptimizedAssets.stylesheets("app", Array(
  "plugins/bootstrap/css/bootstrap.css",
  "plugins/font-awesome/css/font-awesome.css",
  "css/app.css"))

To optionally bundle, minify, and fingerprint javascripts:

@com.fizzed.play.sprockets.OptimizedAssets.javascripts("app", Array(
  "js/jquery-1.10.2.min.js",
  "plugins/bootstrap/js/bootstrap.js", "js/app.js", "js/html5.js"), minify = true)
com.fizzed

Fizzed, Inc.

Helping companies launch and grow their mobile, web, and data products

Versions

Version
1.2.0