Console

I use require.js on the game system, which is great. After setting up the Build.scala file Build.scala I get mini js files in production, but I canโ€™t find information about concatenating all require.js modules into one js file?

I would appreciate it if someone could shed some light or direct me in the right direction.

+4
source share
2 answers

Do you know "webjars" ( http://www.webjars.org )? Webjars is a framework that provides you with Javascript libraries and CSS / frameworks in jar files. You can add them as dependencies to your build file. They also provide some helper function, one of which โ€œcompilesโ€ (combines and minimizes) requirejs-stuff into a single file.

Take a look at the documentation: http://www.webjars.org/documentation They provide some simple examples.

+1
source

I encountered several โ€œerrorsโ€ regarding the integration of requireJS into Play, in 2.2.x.

a) Do not change the file location of your routes. The replay convention, it seems that all public javascripts are in public / javascripts, and your requireJS driver is in app / assets / javascripts.

b) The lines require.sbt require.sbt go below, under "playJavaSettings" or "playScalaSettings" as such:

 name := "TestContcatJS" version := "1.0-SNAPSHOT" libraryDependencies ++= Seq( javaJdbc, javaEbean, cache ) play.Project.playJavaSettings requireJs += "main.js" requireJsShim += "main.js" 

c) You can reference public javascripts in your driver using a relative path. Something like (in main.js):

 require.config({ paths: { 'public-js': '../../public/javascripts' } }); require([ "public-js/foo", "public-js/bar" ]); 
+1
source

Source: https://habr.com/ru/post/1481433/


All Articles