Letractively / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

Maven plugin should allow compress of individual resources #583

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.create one root directory with sub directories.
2.copy css files in subdirectories.
3.Copy some of individual css files under root directory

What is the expected output? What do you see instead?
After minification,keep directory structure as input. I dont want merge or 
group into single file.

What version of the product are you using? On what operating system?
I am using 1.5.0 in windows.

Please provide any additional information below.
i would like to compress individual css and make target directory as same as 
input. google closure compiler will support this method for JS. Attached file 
have sample directory structure. 
Any one please provide customized plugin for css,wro.xml and properties file.

Original issue reported on code.google.com by satishku...@gmail.com on 13 Oct 2012 at 7:04

Attachments:

GoogleCodeExporter commented 8 years ago
How long will it take to resolve..?
Any one please help. I have to finish up this project by 11/15. if wro4j does 
not support then i need to check other resources to compress css.

Original comment by satishku...@gmail.com on 2 Nov 2012 at 7:24

GoogleCodeExporter commented 8 years ago
Usually releases are performed on a monthly basis, based on developed features 
or bug fixes (including the one provided by contributors). 

It is very unlikely that there will be a release with new features (including 
this one) until 11/15. But there is a good news for you:
- wro4j is a tool which can be customized easily based on your needs. This 
requires a little effort on your side.
- there is everything you need: a dozen of processors which can be used 
independently using a simple interface which requires only Reader (to read the 
resource content from) and Writer (where to write the content). You can easily 
traverse the files from a folder and apply a processor on each file. 

Don't forget that this is an open source project, which is developed mainly in 
a spare time with the help of other people willing to contribute. If you find a 
better tool which suites your needs, feel free to use it.

Original comment by alex.obj...@gmail.com on 2 Nov 2012 at 7:37

GoogleCodeExporter commented 8 years ago
Hi, Thanks for Reply.
i didn't mean wro4j is not a good resource. I really appreciating all 
developers effort for developing wro4j.
If you have any sample  Reader (to read the resource content from) and Writer 
(where to write the content) processors, please provide.

Thanks
Satheesh

Original comment by satishku...@gmail.com on 7 Nov 2012 at 12:18

GoogleCodeExporter commented 8 years ago
Most of the stuff are documented on wiki. For instance this is the link where 
you can find how to use a processor in isolation (exactly what you need): 
http://code.google.com/p/wro4j/wiki/ReusingProcessors

Original comment by alex.obj...@gmail.com on 7 Nov 2012 at 12:39

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 30 Nov 2012 at 8:20

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 9 Jan 2013 at 6:28

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 3 Mar 2013 at 9:38

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 21 Mar 2013 at 9:05

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 22 May 2013 at 8:33

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 8 Jun 2013 at 9:50

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 13 Sep 2013 at 3:54

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 5 Nov 2013 at 1:54

GoogleCodeExporter commented 8 years ago
Can you, please, provide some pointers on how to best implement this at 
build-time? Is there a way to register custom processors and/or model 
transformers using the Maven plugin?
Also, I would probably be interested in implementing this feature in wro 
itself, but need some guidelines. Should it be a Transformer that makes a group 
out each individual element? Or a way to mark a group as "virtual", so it 
doesn't actually get concatenated?

Original comment by veg...@gmail.com on 3 Dec 2013 at 12:52

GoogleCodeExporter commented 8 years ago
The reason why this was not yet implemented, is because it is not clear yet 
what is the preferred use-case. More specifically, you could compress 
individual resources using several different approaches:

1) Specify a source folder (no wro.xml involed) where the "source" resources 
are located which will be minified, and a target folder - where the minified 
resources will be created.

2) Use the wroModel (wro.xml) to identify the resources required to be minified 
and process them one by one. The problem with this approach is that the 
resources defined in wro.xml are not necessarily context relative resources. 
They could be also a classpath resources or external url's. As result, it is 
not clear where exactly the minified resources should be located. It might be 
possible to provide some sort of strategy which would be responsible for 
identifying the target path of the minified resources based on resource uri. 

In conclusion, before starting any implementation, it worth discussing how 
exactly would you want this plugin to work. What is your specific use-case. 
Based on your feedback, we might decide what is the best way to implement it. 

Original comment by alex.obj...@gmail.com on 3 Dec 2013 at 8:17

GoogleCodeExporter commented 8 years ago
The use case I constantly run into is the following: a directory structure 
exists with resources that can only be optimized individually and in-place. The 
reason for this is that different products (frameworks, applications etc.) 
already have certain static resources and expectations about their names and 
locations that we can do nothing about, so no moving/bundling/renaming is 
possible. Another scenario is almost the same, but resources do not need to be 
optimized in-place, but are still needed individually, as they belong to 
completely stand-alone, reusable elements that load them through require.js 
(think of reusable widgets/portlets). Here, it is possible to just make a group 
per widget/portlet, but there might be dozens of them, and they often have a 
single .js and a single .css resource (happens frequently to me), so just 
mapping them all in one go would certainly help.

[From this point on, I'm stepping out of my own use-case, and all I say is very 
likely just a rant, so please forgive I speak nonsense]
I'm imagining something like <group logical="true" inplace="true" ...> in 
wro.xml, where "logical" would mean no actual file concatenation takes place 
and "inplace" would mean the original files should be replaced with optimized 
ones).
Generally, I'm thinking that as long as a build-time solution is used and the 
output directory is specified, it is easy, as it does not matter where the 
resources are coming from. For runtime solutions (of which I know much less) it 
might be reasonable to just retain the original resource names and serve them 
when the name matches (while keeping the optimized files wherever they are kept 
now i.e. memory or some temporary disk location). E.g. when style.css is 
requested, it gets processed and served if there was a matching entry in a 
"logical" group, regardless if it was defined as $classpath/style.css or 
www.example.com/style.css. Of course, in this case, in-place optimization is 
not possible as one can not overwrite a remote file or something packaged into 
a .war (i.e. inplace="false" for all such resources).

Original comment by veg...@gmail.com on 3 Dec 2013 at 11:38

GoogleCodeExporter commented 8 years ago
You should not forget that the resources specified in wroModel (usually located 
in wro.xml, but also could be wro.groovy or any other custom DSL), are not 
always context relative physical resources. These can be classpath resources, 
external url's or dynamically generated resources. Therefore, the "inplace" 
attribute can't apply, since you can't replace a file at some arbitrary 
location were you don't have rights.

When your wroModel contains only context relative resources (which is the case 
for most of the users), then this can work. But I'm against adding new 
attributes to the wro.xml which doesn't really make sense for everybody. 

This is the reason why I described those two approaches in my previous post, 
where youcan see that a separate maven "goal" would be implemented. Besides 
your use-case, there might be other variations and it is important to make it 
easy to customize to avoid the need of a new goal for each new use-case.

Original comment by alex.obj...@gmail.com on 3 Dec 2013 at 11:50

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 8 Jan 2014 at 3:12

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 21 Mar 2014 at 9:20

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 8 Apr 2014 at 9:56

GoogleCodeExporter commented 8 years ago

Original comment by alex.obj...@gmail.com on 18 Jun 2014 at 11:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
i don't know why... when i'm using wro4j with spring framework works awesome, 
but when i integrate it with simple mvc structure it's not working. can any one 
send some sample for this, ASAP. 
Thank you,
Raj.

Original comment by nagar...@ayatilabs.com on 14 Oct 2014 at 10:45

GoogleCodeExporter commented 8 years ago
@nagaraju - there are plenty of examples. One of them, using maven plugin 
without spring is here: 
https://github.com/wro4j/wro4j-examples/tree/master/wro4j-standalone

Original comment by alex.obj...@gmail.com on 14 Oct 2014 at 11:27