Alfresco / alfresco-sdk

The Alfresco In-Process SDK is based on Apache Maven, includes support for rapid and standard development, testing, packaging, versioning and release of your Alfresco integration and extension projects
Apache License 2.0
186 stars 113 forks source link

Extra filter needed for yuicompressor #378

Closed tom-vandepoele closed 7 years ago

tom-vandepoele commented 8 years ago

SDK 2.2.0 (probably older versions too):

Yuicompressor should not minimise files in

src/main/amp/config/alfresco/web-extension/templates

in the share-amp.

Any js file there is using webscript (rhinoscript) js, so can use imports etc., which break the build when yuicompressor tries to minimise them.

ohej commented 7 years ago

SDK3 does no longer have JS compression by default. As mentioned in #423, we will add documentation around how this is configured

ghost commented 7 years ago

Hi,

I can't find the documentation for this. Please help me with the link.

I have tried on my own and I am able to create the *-min.js file for the overridden OOTB js file but it doesn't seems to be getting copied in the war and the amp that is created using run.sh. Below is the configuration that I am using in my project.

`

net.alchim31.maven
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.5.1</version>
            <executions>
                <execution>
                    <id>compress-js</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                    <configuration>
                        <excludes>
                            <exclude>**/webscripts/**</exclude>
                            <exclude>**/site-webscripts/**</exclude>
                            <exclude>**/*.lib.js</exclude>
                            <exclude>**/*.css</exclude>
                        </excludes>
                        <warSourceDirectory>src/main/resources/META-INF</warSourceDirectory>
                                                    <!-- Below line I have added for the minification of the js files in the web folder-->
                        <warSourceDirectory>src/main/assembly/web</warSourceDirectory>
                        <jswarn>false</jswarn>
                    </configuration>
                </execution>
            </executions>
        </plugin>`
douglascrp commented 7 years ago

@rastoh Hello. Any new on this? It is a shame this is not working at all, and there is no useful documentation on the topic.

tom-vandepoele commented 7 years ago

@rastoh @douglascrp

I use this configuration, probably can be optimized:

<plugin> <groupId>net.alchim31.maven</groupId> <artifactId>yuicompressor-maven-plugin</artifactId> <version>1.4.0</version> <!-- ensure YUI Compressor 2.4.8-rhino-alfresco-patched is used - as 2.4.7 is the default --> <dependencies> <dependency> <groupId>com.yahoo.platform.yui</groupId> <artifactId>yuicompressor</artifactId> <version>2.4.8-rhino-alfresco-patched</version> </dependency> </dependencies> <configuration> <jswarn>false</jswarn> <encoding>UTF-8</encoding> <excludeResources>true</excludeResources> </configuration> <executions> <execution> <id>minimize-slingshot-javascript</id> <goals> <goal>compress</goal> </goals> <phase>prepare-package</phase> <configuration> <includes> <include>META-INF/**/*.js</include> </includes> <excludes> <exclude>META-INF/**/*-min.js</exclude> <exclude>META-INF/js/lib/**</exclude> </excludes> <sourceDirectory>${project.build.directory}/classes</sourceDirectory> <outputDirectory>${project.build.directory}/classes</outputDirectory> </configuration> </execution> <execution> <id>minimize-assembly-javascript</id> <goals> <goal>compress</goal> </goals> <phase>prepare-package</phase> <configuration> <includes> <include>**/*.js</include> </includes> <excludes> <exclude>**/*-min.js</exclude> </excludes> <sourceDirectory>${project.basedir}/src/main/assembly/web</sourceDirectory> <outputDirectory>${project.basedir}/src/main/assembly/web</outputDirectory> </configuration> </execution> </executions> </plugin>

As mentioned by douglascrp, it's best to put a .gitignore on /src/main/assembly/web/*/-min.js Compare my configuration with his here: https://douglascrp.blogspot.be/2017/11/how-to-add-missing-minification-of.html https://gist.github.com/douglascrp/5feeb78e76866464418bff27259049f8#file-alfresco-sdk-3-0-with-minificatio-of-javascript-files-xml

douglascrp commented 7 years ago

@tom-vandepoele Thank you for your answer. I am going to test your config soon. But let me ask you this... why do you need the compressor patched version? Do you know about what got patched?

tom-vandepoele commented 7 years ago

@douglascrp if I recall correctly webscript js (rhinoscript) files (think: alfresco js api) had issues if I didn't include that modified dependency. On regular (front-end) js files I don't think it makes any difference.

douglascrp commented 7 years ago

@tom-vandepoele That is what I thought. But thinking about the server side javascripts (webscripts), why to compress them?

tom-vandepoele commented 7 years ago

@douglascrp I can't really answer that, as it's been quite some time since I had the problem. Unfortunately I didn't write down the specifics. (Did a quick look through my projects code stacks to see if I could dig it up, but nothing came up)

As for why alfresco patched the yuicompressor jar, maybe this (older) ticket might shed some light: https://issues.alfresco.com/jira/browse/ALF-13989 (problems with unicode characters in js)

For full patch details, someone at Alfresco might know. @ohej any insight in this matter?