Currently I am working on a JavaScript application and I am trying to build it as modular as possible. What I'm planning to do is to get a folder structure like
js
|__ controllers
|__ services
|__ directives
index.html
I am using angularjs and i want to split all the controllers and services into seperate files.
I am a Java-Developper and I want to use maven to build this project and deploying it on a tomcat.
In production mode i want to a compressor/obfuscator to pack all files into one single application.js. Normally when I build my projects i only got one file for all controllers and one for all services and so on. So what I am doing is have one profile for dev and one for live and with filtering I append .min.js in my index.html to include all the files ( minimized on live, non-minimized on dev )
Finally my question:
What is the best way to do that with multiple files?
In development mode i want
<script type="text/javascript" src="MyFirstController.js">
<script type="text/javascript" src="MySecondController.js">
<script type="text/javascript" src="MyThirdController.js">
<script type="text/javascript" src="MyFirstService.js">
/* ... */
And in production mode i only want one file included in my index.html
<script type="text/javascript" src="myapp.js">
The first solution but clearly a not very pretty solution would be to have a multiline property in my maven file where i got all the script tags which i then replace with filtering.
I hope someone can tell me a good solution for my problem. Thanks in advance!