SlideShare a Scribd company logo
Intro to sbt-web 
Asset handling in Play 2.3 
Marius Soutier! 
Freelance Scala Developer 
@mariussoutier
Motivation 
• Play’s client-side support not flexible enough, 
too opinionated which technologies it supports 
• Can’t keep up with speed of innovation in the 
JavaScript world (see JavaScript drinking game) 
• If you can’t beat ‘em, join ‘em 
Adopt Node APIs and make them run on the JVM 
at full speed 
• Factor out asset handling into sbt plugins to build 
community independent from Play
Enter sbt-web 
sbt 
sbt-web! 
Project Layout! 
Assets! 
Error Reporting 
sbt-js-engine! 
Execute JavaScript in sbt! 
Trireme / Node / Nashorn 
sbt-js-task! 
Write sbt tasks that execute! 
JavaScript using js-engine! 
WebJars! 
Dependency 
Management 
sbt-web-driver! 
Execute DOM-based JavaScript! 
WebDriver 
- But let’s focus on sbt-web today -
Just Enough sbt 
• .sbt and .Scala build files 
• Build is an immutable collection of 
key-value pairs (String -> T) 
• Tasks are computed settings 
• Assign / override values via := 
Setting[Task[T]] 
name := “demo” 
• Append / override values via +=, ++= 
Setting[T] 
libraryDependencies += “org.webjars” % …
Scopes 
• Settings are scoped by project, configuration, or task; 
default configuration is Global 
• Reuse existing settings and scope them for your needs 
compile in Compile 
compile in Test 
sourceDirectory in (Compile, packageBin)
Setting Dependencies 
target 
webTarget 
staging 
Directory 
Settings depend on other settings 
Eases making small changes 
target/web/stage/ 
target := “target” 
webTarget := target.value / “web” 
webStaging := webTarget.value / “stage” 
Global 
Configuration
Inspecting settings 
• show <setting-key> to check the value of a setting or 
result of a task 
• inspect <setting-key> to understand setting’s 
hierarchy and dependencies 
• Use the key, not the name of the val in code 
• Access scoped settings via <scope>:<setting-key>
Default Project Layout 
- Play overrides src/main to app -
public 
Global webTarget 
Test Assets 
Directories 
Assets 
Plugin 
source 
Directory 
source 
Managed 
resource 
Directory 
resource 
Managed 
webModules 
Lib 
nodeModule 
Directory 
webModule 
Directory 
nodeModule 
Directory 
public 
source 
Directory 
source 
Managed 
resource 
Directory 
resource 
Managed 
webModule 
Directory 
nodeModule 
Directory 
staging 
Directory
Test Assets 
Tasks 
Assets 
assets 
Global 
node 
Modules 
web 
Modules 
webJars 
stage pipeline 
assets 
assets 
… 
compile 
compile test
Source Tasks 
Compile sources to public assets 
Analyze sources 
Integrates with error reporting 
CoffeeScript 
*.coffee 
JavaScript 
LESS 
*.less 
CSS 
src/main/assets/ 
target/ 
web/ 
public/ 
sourceDirectory in Assets public in Assets 
sources in Assets resources-managed/ 
main/ 
resourceManaged in Assets
Asset Pipeline 
Input 
Assets 
Name 
Hashing 
(digest) 
GZip 
Output 
Assets 
Tasks operating on assets sequentially 
Each stage operates on mappings and passes to next one 
pipelineStages := Seq(digest, gzip) 
Play’s Assets router is aware of both digested and gzipped assets
Source Plugins 
sbt-coffeescript Convert CoffeeScript to JavaScript 
sbt-jshint JavaScript linting 
sbt-stylus CSS preprocessor 
sbt-less CSS preprocessor 
sbt-mocha Server-Side JS Testing 
sbt-scalajs Convert ScalaJS to JavaScript (TODO)
Asset Plugins 
sbt-digest Fingerprinting 
sbt-gzip Gzip assets 
sbt-rjs RequireJS integration, minify JavaScript 
sbt-uglify Minify/uglify JavaScript (without RequireJS)
WebJars 
• Client-side dependency management, including transitive 
dependencies 
• Packed in Jars, resolved like normal dependencies 
by sbt 
libraryDependencies += "org.webjars" % "bootstrap" % "3.2.0" 
• sbt-web auto-extracts WebJars to 
target/web/web-modules/lib 
• Mapped to jsDelivr CDN automatically by Play’s Assets controller 
• Assets in sub-projects are exported as a WebJar
NPM 
• Node Package Manager 
• Becoming popular for client-side dependencies 
• js-engine resolves and auto-extracts dependencies 
defined in package.json 
• Disclaimer: Does not seem to work 100% yet
Writing sbt-web tasks 
- Demo -

More Related Content

What's hot

High Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. ThreadedHigh Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. Threaded
Engine Yard
 
A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...
Codemotion
 
Mssql to mysql - Anton Ivanov
Mssql to mysql - Anton IvanovMssql to mysql - Anton Ivanov
Mssql to mysql - Anton Ivanov
DrupalCamp Kyiv
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
scalaconfjp
 
Django Multi-DB in Anger
Django Multi-DB in AngerDjango Multi-DB in Anger
Django Multi-DB in Anger
Loren Davie
 
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
Workload Replay in the Cloud: Secret Weapon for Cloud MigrationsWorkload Replay in the Cloud: Secret Weapon for Cloud Migrations
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
John Sterrett
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
Chris Westin
 
Jenkins Job Builder: our experience
Jenkins Job Builder: our experienceJenkins Job Builder: our experience
Jenkins Job Builder: our experience
Timofey Turenko
 
Configuring a more secure BOSH
Configuring a more secure BOSHConfiguring a more secure BOSH
Configuring a more secure BOSH
Saman Alvi
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
Raimonds Simanovskis
 
[PL] Code Europe 2016 - Python and Microsoft Azure
[PL] Code Europe 2016 - Python and Microsoft Azure[PL] Code Europe 2016 - Python and Microsoft Azure
[PL] Code Europe 2016 - Python and Microsoft Azure
Michał Smereczyński
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!
Dimitri Gielis
 
BackboneJS and friends
BackboneJS and friendsBackboneJS and friends
BackboneJS and friends
Scott Cowan
 
RESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 versionRESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 version
Bertrand Delacretaz
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee
 
HTML5 Hacking - Yahoo! Open Hack Day
HTML5 Hacking - Yahoo! Open Hack DayHTML5 Hacking - Yahoo! Open Hack Day
HTML5 Hacking - Yahoo! Open Hack Day
Ted Drake
 
Neoito — React 101
Neoito — React 101Neoito — React 101
Neoito — React 101
Neoito
 
N:1 Replication meets MHA
N:1 Replication meets MHAN:1 Replication meets MHA
N:1 Replication meets MHA
do_aki
 
React.js触ってみた 吉澤和香奈
React.js触ってみた 吉澤和香奈React.js触ってみた 吉澤和香奈
React.js触ってみた 吉澤和香奈
Wakana Yoshizawa
 
Scalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on RailsScalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on Rails
Jared Rosoff
 

What's hot (20)

High Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. ThreadedHigh Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. Threaded
 
A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...
 
Mssql to mysql - Anton Ivanov
Mssql to mysql - Anton IvanovMssql to mysql - Anton Ivanov
Mssql to mysql - Anton Ivanov
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Django Multi-DB in Anger
Django Multi-DB in AngerDjango Multi-DB in Anger
Django Multi-DB in Anger
 
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
Workload Replay in the Cloud: Secret Weapon for Cloud MigrationsWorkload Replay in the Cloud: Secret Weapon for Cloud Migrations
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
 
Jenkins Job Builder: our experience
Jenkins Job Builder: our experienceJenkins Job Builder: our experience
Jenkins Job Builder: our experience
 
Configuring a more secure BOSH
Configuring a more secure BOSHConfiguring a more secure BOSH
Configuring a more secure BOSH
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
[PL] Code Europe 2016 - Python and Microsoft Azure
[PL] Code Europe 2016 - Python and Microsoft Azure[PL] Code Europe 2016 - Python and Microsoft Azure
[PL] Code Europe 2016 - Python and Microsoft Azure
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!
 
BackboneJS and friends
BackboneJS and friendsBackboneJS and friends
BackboneJS and friends
 
RESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 versionRESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 version
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
HTML5 Hacking - Yahoo! Open Hack Day
HTML5 Hacking - Yahoo! Open Hack DayHTML5 Hacking - Yahoo! Open Hack Day
HTML5 Hacking - Yahoo! Open Hack Day
 
Neoito — React 101
Neoito — React 101Neoito — React 101
Neoito — React 101
 
N:1 Replication meets MHA
N:1 Replication meets MHAN:1 Replication meets MHA
N:1 Replication meets MHA
 
React.js触ってみた 吉澤和香奈
React.js触ってみた 吉澤和香奈React.js触ってみた 吉澤和香奈
React.js触ってみた 吉澤和香奈
 
Scalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on RailsScalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on Rails
 

Similar to Intro to sbt-web

Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
Marius Soutier
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
Kevin Webber
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
rajdeep
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Andrew Rota
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k
IBM
 
Rad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh KRad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh K
Roopa Nadkarni
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
Meetup developing building and_deploying databases with SSDT
Meetup developing building and_deploying databases with SSDTMeetup developing building and_deploying databases with SSDT
Meetup developing building and_deploying databases with SSDT
Solidify
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Arun Gupta
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
Shahid Shaik
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
Anand kalla
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should Know
Spiffy
 
Maven
MavenMaven
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
London Microservices
 
Maven
MavenMaven
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With Gatsby
Imran Sayed
 
Struts2-Spring=Hibernate
Struts2-Spring=HibernateStruts2-Spring=Hibernate
Struts2-Spring=Hibernate
Jay Shah
 

Similar to Intro to sbt-web (20)

Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k
 
Rad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh KRad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh K
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Meetup developing building and_deploying databases with SSDT
Meetup developing building and_deploying databases with SSDTMeetup developing building and_deploying databases with SSDT
Meetup developing building and_deploying databases with SSDT
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should Know
 
Maven
MavenMaven
Maven
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
 
Maven
MavenMaven
Maven
 
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With Gatsby
 
Struts2-Spring=Hibernate
Struts2-Spring=HibernateStruts2-Spring=Hibernate
Struts2-Spring=Hibernate
 

Recently uploaded

Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 

Recently uploaded (20)

Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 

Intro to sbt-web

  • 1. Intro to sbt-web Asset handling in Play 2.3 Marius Soutier! Freelance Scala Developer @mariussoutier
  • 2. Motivation • Play’s client-side support not flexible enough, too opinionated which technologies it supports • Can’t keep up with speed of innovation in the JavaScript world (see JavaScript drinking game) • If you can’t beat ‘em, join ‘em Adopt Node APIs and make them run on the JVM at full speed • Factor out asset handling into sbt plugins to build community independent from Play
  • 3. Enter sbt-web sbt sbt-web! Project Layout! Assets! Error Reporting sbt-js-engine! Execute JavaScript in sbt! Trireme / Node / Nashorn sbt-js-task! Write sbt tasks that execute! JavaScript using js-engine! WebJars! Dependency Management sbt-web-driver! Execute DOM-based JavaScript! WebDriver - But let’s focus on sbt-web today -
  • 4. Just Enough sbt • .sbt and .Scala build files • Build is an immutable collection of key-value pairs (String -> T) • Tasks are computed settings • Assign / override values via := Setting[Task[T]] name := “demo” • Append / override values via +=, ++= Setting[T] libraryDependencies += “org.webjars” % …
  • 5. Scopes • Settings are scoped by project, configuration, or task; default configuration is Global • Reuse existing settings and scope them for your needs compile in Compile compile in Test sourceDirectory in (Compile, packageBin)
  • 6. Setting Dependencies target webTarget staging Directory Settings depend on other settings Eases making small changes target/web/stage/ target := “target” webTarget := target.value / “web” webStaging := webTarget.value / “stage” Global Configuration
  • 7. Inspecting settings • show <setting-key> to check the value of a setting or result of a task • inspect <setting-key> to understand setting’s hierarchy and dependencies • Use the key, not the name of the val in code • Access scoped settings via <scope>:<setting-key>
  • 8. Default Project Layout - Play overrides src/main to app -
  • 9. public Global webTarget Test Assets Directories Assets Plugin source Directory source Managed resource Directory resource Managed webModules Lib nodeModule Directory webModule Directory nodeModule Directory public source Directory source Managed resource Directory resource Managed webModule Directory nodeModule Directory staging Directory
  • 10. Test Assets Tasks Assets assets Global node Modules web Modules webJars stage pipeline assets assets … compile compile test
  • 11. Source Tasks Compile sources to public assets Analyze sources Integrates with error reporting CoffeeScript *.coffee JavaScript LESS *.less CSS src/main/assets/ target/ web/ public/ sourceDirectory in Assets public in Assets sources in Assets resources-managed/ main/ resourceManaged in Assets
  • 12. Asset Pipeline Input Assets Name Hashing (digest) GZip Output Assets Tasks operating on assets sequentially Each stage operates on mappings and passes to next one pipelineStages := Seq(digest, gzip) Play’s Assets router is aware of both digested and gzipped assets
  • 13. Source Plugins sbt-coffeescript Convert CoffeeScript to JavaScript sbt-jshint JavaScript linting sbt-stylus CSS preprocessor sbt-less CSS preprocessor sbt-mocha Server-Side JS Testing sbt-scalajs Convert ScalaJS to JavaScript (TODO)
  • 14. Asset Plugins sbt-digest Fingerprinting sbt-gzip Gzip assets sbt-rjs RequireJS integration, minify JavaScript sbt-uglify Minify/uglify JavaScript (without RequireJS)
  • 15. WebJars • Client-side dependency management, including transitive dependencies • Packed in Jars, resolved like normal dependencies by sbt libraryDependencies += "org.webjars" % "bootstrap" % "3.2.0" • sbt-web auto-extracts WebJars to target/web/web-modules/lib • Mapped to jsDelivr CDN automatically by Play’s Assets controller • Assets in sub-projects are exported as a WebJar
  • 16. NPM • Node Package Manager • Becoming popular for client-side dependencies • js-engine resolves and auto-extracts dependencies defined in package.json • Disclaimer: Does not seem to work 100% yet