JavaScript minimization workflow with Maven

I'm wondering what “best practices” integrate the “modern JavaScript build workflow” into the Maven build, which creates a WAR artifact.

I found several maven plugins that handle concatenation and minimization:

However, I still do not understand how they fit into the workflow of a complete assembly, since I believe that it is necessary to enable / disable concatenation / minimization:

For development, I want to create a WAR that does not contain concatenated / mined resources so that I can debug conveniently. To build an assembly, I want to create a WAR that contains concatenated / mined resources.

Also, to build the assembly, I have to “rewrite” the script URLs in my html to indicate a concatenation / smaller version of script (s).

In the JavaScript world, I would use Grunt with various grunt tasks (uglify, usemin) to achieve the above workflow. How can I achieve the same in a Maven assembly?

+4
source share
2 answers

You should be able to run maven with different profiles so that you can minimize js scripts to build the assembly, but create it locally with a different profile for debugging purposes.

More information about this can be found on the Maven profile page.

Hope this helps.

+3
source

Since you mentioned Grunt, did you think that you were invoking Grunt tasks directly from your Maven assembly? This is not an ideal solution, but it gives you a few more options without relying on Maven plugins. http://addyosmani.com/blog/making-maven-grunt/

Also, this SO theme: Javascript web application and Java server, build everything in Maven or use Grunt for web application?

+3
source

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


All Articles