score:3
Accepted answer
you will have to use a jsx compilation plugin that you can use to compile .jsx files into .js, for example this: https://github.com/ddispaltro/sbt-reactjs
you will then need to use different import blocks in your templates depending on if running as in dev or prod, something like this:
@if(play.api.play.current.mode == play.api.mode.prod) {
<script src="@routes.assets.at("lib/react/react.js")" type="text/javascript" ></script>
<script src="@routes.assets.at("javascripts/reactapp.js")" type="text/jsx"></script>
} else {
<script src="@routes.assets.at("lib/react/react.js")" type="text/javascript" ></script>
<script src="@routes.assets.at("lib/react/jsxtransformer.js")" type="text/javascript" ></script>
<script src="@routes.assets.at("javascripts/reactapp.jsx")" type="text/jsx"></script>
}
more elaborate setups can be achieved using requirejs and other module managing schemes, but this is the simplest solution in a small project imho.
Source: stackoverflow.com
Related Query
- Play Framework with React in Webjar
- How to use IntelliJ with Play Framework and Scala
- "host not allowed" error when deploying a play framework application to Amazon AWS with Boxfuse
- Dependency injection with abstract class and object in Play Framework 2.5
- Which is best data access options available for Play framework with Scala and PostgreSQL?
- Play Framework - Redirect with params
- Dynamic SQL Parameters with Anorm and Scala Play Framework
- How to schedule an hourly job with Play Framework 2.1?
- How to create a global variable with Play Framework 2.0
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- Play Framework REST with basic authentication and SSL
- How to print @ symbol in HTML with play framework (scala)
- Testing request with CSRF Token in Play framework 2.5 (Scala)
- How to run Play Framework 2.2.0 with -feature option
- Using Spring as a dependency injection framework with play 2.4.x?
- Play Framework & Scala: Problems with FakeRequest & JSON POST in unit test
- Debug not working with play framework activator, scala and eclipse
- Composing `Future` result in Play Framework with Scala
- How to set up play framework ApplicationLoader and Macwire to work with custom routes?
- Play Framework PathBindable with Dependency Injection
- Implicit Messages Provider instance was not found in Play framework with scala
- Using SORM with Play Framework 2.3.8
- Chunked Response from an Iterator with Play Framework in Scala
- Cannot resolve symbol 'play' error with Play Framework 2.4.x and IntellijIdea 14.x
- @Repeat Form Helper with complex object - Play Framework
- How i can integrate Apache Spark with the Play Framework to display predictions in real time?
- How to tune Play Framework application with proper threadpools?
- play framework 2: test a request with a json string as body
- Sending POST Request to Twitter API with Play Framework 2.0
- Unit testing file upload in a controller with Java Play Framework 2.3.x
More Query from same tag
- How can I check whether a Double value overflows?
- How to get a reference to the actor instance that runs a function?
- How to filter data based on three columns in Scala
- How to extract multiple string part from string in scala?
- Scala implicit constructor
- IllegalAccessError when running spark job in EMR
- is CPU usage in Apache Spark limited?
- Single Queue and multiple consumers in RabbitMQ
- Swing Scala Question - 100% expansion of panel
- Spark CSV package not able to handle \n within fields
- Sort JSON Output Alphabetically
- Is for-yield-getOrElse paradigmatic Scala or is there a better way?
- Scala: Sum values across arrays based on key
- How to aggregate values to a list of maps after group by?
- Spark Scala UDF NullPointer Exception
- Column type not defined while upgrading from slick 2.1 to slick 3.2 in scala
- Naive Bayes with Apache Spark MLlib
- Enabling the macro-paradise Scala compiler plugin in Maven projects
- Scala tuple unpacking for constructors with abstract class for inheritance
- functional approach suggestions instead of using mutablelist
- run scala program in java jar file
- Akka Typed and having base class for MessageAdapters
- Is it correct to return IndexesSeq instead of Array if an immutable array is needed in Scala?
- How do I implement a collection in Scala 2.8?
- Cannot apply [-] to AnyVal in scala
- Error adding VectorAssembler to Spark ML Pipeline
- How to remember the choice of the run type in Eclipse?
- Checking ClassManifest for subtypes in Scala
- Return type depending on parameter type (e.g. Await.ready()) does not work as expected
- Base64 and binary streams between Java and C#