Open FagnerMartinsBrack opened 10 years ago
By default, the group name is used as the final name of the minified resource. It doesn't create folders. In theory, producing folders when the group name contains "/" characters is possible. Currently, the only solution to control the folder is to configure "jsDestinationFolder" property. I could make this possible. It would really help to understand better your use-case.
As a note, there is an open issue which aims to produce a minimized resource for each processed resource at a predefined location. But I'm not sure if this feature would be useful for you.
I see jsDestinationFolder
only allows a single folder to be used (at least that's how it is documented). So it wouldn't fit my purposes.
The aim here is to concatenate some files and keep others as is, but be able to separate them in directories. This way I could be able to create a better organized structure for dynamic calls in the front end as:
require([
"jquery",
"angular/controllers/TagsController",
"angular/directives/TagDirective"
], function( $, TagsController, TagDirective ) {
// ...
});
there is an open issue which aims to produce a minimized resource for each processed resource at a predefined location
Do you mean #122?
The real solution here would be to concatenate my files using requireJS, but since this is not supported, a directory separation is needed to maintain the structure well organized.
I mean this issue: https://code.google.com/p/wro4j/issues/detail?id=583&can=1&q=Milestone%3DRelease-1.7.5
I think wro4j and requireJS have overlapping features. Using both of them is not very straightforward. Nevertheless, I'm keen to make wro4j as friendly as possible with other tools.
That issue is kind of similar.
It's unfortunate wro4j have overlapping features, it would be very nice some kind of "2.0" version with a different approach :D
I would appreciate if you could elaborate on the meaning of "different". There are dozen of approach for similar problems. A project should evolve on specific needs. It would be a waste of time and effort to clone an existing tool. Don't get me wrong, I'm just trying to understand better your requirements.
My suggestion of "different" would be leverage AMD for files concatenation or provide means to easly do so. Currently it concatenates everything based on specific approaches provided by wro4j and it is impossible to leverage requireJS in any way (except creating separate files for minification).
To be a little more clear:
Currently I use wro.xml to map js files and load asynchronously using define
and require
. wro4j could concatenate everything using requireJS and provide a single file (maybe using the requireJS optimizer tool r.js
).
If the r.js would be used by wro4j, what would be the wro4j purpose? I'm not sure I understand the entire picture. What exactly is the reason of not using require.js exclusively for your use-case? I know, it sounds weird that I ask that, but I would like to have a better understanding of the problem.
I use wro4j maven plugin to pre process less and concatenate files that do not support AMD, like prepending a require-intro.js
and appending a require-outro.js
for each one of them and make them requireJS modules for my app only.
I prefer write my non-AMD plugins as modules on the fly instead of using shim configs.
In that case, from your point of view, what is the ideal workflow of wro4j maven plugin (it could be also a different goal) which would fit for your use-case? Saying that it should concatenate everything using requireJS is not enough. The requirements should be more specific.
This is the phase where we can define new requirements.
My workflow suggestion would be to configure requireJS files somehow and define an output. Then wro4j would load those files, process with r.js
and create the output, minifying everything in the process.
Maybe use a pattern to specify the files to be considered, or wro4j could read the files and check for define
presence.
Does that makes sense?
It probably makes sense, but still is not specific enough. Starting with a basic example would help. Defining how exactly the requireJS should be configured, what exactly the process does and how the files are checked (checking for define presence probably is not enough). Should rhino be used for this? You should be aware that any processing involving rhino becomes very slow. The node.js alternative is not easy to make platform independent, while nashorn support is available only in java 8 which is not adopted yet by most of the project.
The most difficult part, is to describe the requirements in detail. That is why your help is very valuable.
I understand the issues to create something like that. The idea would be to use rhino or node/phantomJS, the only two solutions that exist today.
If it is too hard I think the only solution for my end would be using grunt and integrate the build system with eclipse and maven using phantomJS.
I agree that the best tools are those which solves the problems you have. I'm not claiming that wro4j is a silver bullet solution. If using grunt does fit your needs, than probably it is the best tool for you. I'm open to add new features, but in order to make this happen - community should get involved as well.
Thank you for your feedback.
Just a follow-up. I have been reading this issue again thought it would be worth the comment:
If using grunt does fit your needs, than probably it is the best tool for you.
Except it is not, grunt is the same as maven and have no integration with eclipse. I use eclipse and maven for my front-end and back-end development, I do not use grunt because I have no ideia of how to integrate it in my workflow inside maven build lifecycle.
There is no reason for using yet another build tool along with maven. Wro4j is the only tool that I just write some XML and start using it, and that is why I am using it instead of another build tool for front-end resources.
@alexo, I have open sourced a project so you can see my workflow using requireJS and wro4j.
As you can see here I have my JS files. Here I configure each file that I want to concatenate, the files are created in a local /static/
folder (as configured here)
The main purpose of this issue is the lack to be able to concatenate files and output them to an specific directory, so I can load using require( ["jquery/validate"] )
for instance.
The previous "requireJS and wro4j" conversation doesn't seems to be related (unless you think a more robust support is strictly necessary to make it work).
Check here how I am loading my resources through AMD.
Looking through the docs I couldn't find a solution, sorry to post here if this feature already exists.
The plugin currently does not support minification of resources with angularJS or requireJS in mind, so I am creating an app with multiple javascript files separated by directories and minifying them as necessary using wro4j maven plugin.
The problem is that the wro.xml does not allow me to output the minified resources in a separate directory from the
js
root folder.This will not create the directories:
<group name="angular/controllers/MyController.js"> ... </group>
Is this feature feasible to be implemented or this is out of scope of the project?
I ask this because I am thinking into change my minification and concatenation process, wro4j does not seems to be enough for the most used front-end tools out there.
Any thoughts?