This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 966a63e  modifications to support minification of CSS file in 
js-release solves in part apache/royale-compiler#39 Now needs more work of 
final minify process
966a63e is described below

commit 966a63eeb353632b1ea3ab621acefb6ee18b1483
Author: Carlos Rovira <carlosrov...@apache.org>
AuthorDate: Sun Apr 8 20:15:15 2018 +0200

    modifications to support minification of CSS file in js-release solves in 
part apache/royale-compiler#39
    Now needs more work of final minify process
---
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 36 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
index d006087..0335f24 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
@@ -424,11 +424,11 @@ public class MXMLRoyalePublisher extends JSGoogPublisher 
implements IJSPublisher
         project.needCSS = gdw.needCSS;
         if (project.needCSS || googConfiguration.getSkipTranspile()) {
             if (!googConfiguration.getSkipTranspile()) {
-                writeCSS(projectName, intermediateDir);
+                writeCSS(projectName, intermediateDir, false);
             }
             if (project.needCSS && configuration.release()) {
-                FileUtils.copyFile(new File(intermediateDir, projectName + 
".css"),
-                        new File(releaseDir, projectName + ".css"));
+                // if release version minify css string
+                writeCSS(projectName, releaseDir, true);
             }
         }
 
@@ -651,7 +651,13 @@ public class MXMLRoyalePublisher extends JSGoogPublisher 
implements IJSPublisher
             bgcolor = ta.getBackgroundColor();
             pageTitle = ta.getPageTitle();
         }
-        String result = input.replaceAll("\\$\\{application\\}", 
mainClassQName);
+
+        String result = null;
+        if (type.equals("release")) {
+            result = input.replaceAll("\\$\\{application\\}", mainClassQName + 
".min");
+        } else {
+            result = input.replaceAll("\\$\\{application\\}", mainClassQName);
+        }
         if (bgcolor != null)
             result = result.replaceAll("\\$\\{bgcolor\\}", bgcolor);
         //result = result.replaceAll("\\$\\{expressInstallSwf\\}", 
expressInstallSwf);
@@ -730,7 +736,13 @@ public class MXMLRoyalePublisher extends JSGoogPublisher 
implements IJSPublisher
         htmlFile.append("<head>\n");
         htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" 
content=\"IE=edge,chrome=1\">\n");
         htmlFile.append("\t<meta http-equiv=\"Content-Type\" 
content=\"text/html; charset=utf-8\">\n");
-        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" 
href=\"").append(projectName).append(".css\">\n");
+        
+        // if release version want to call minified css file, while in debug 
the non minified one
+        if (type.equals("release")) {
+            htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" 
href=\"").append(projectName).append(".min.css\">\n");
+        } else {
+            htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" 
href=\"").append(projectName).append(".css\">\n");
+        }
 
         htmlFile.append(getTemplateAdditionalHTML(additionalHTML));
         htmlFile.append(getTemplateDependencies(type, projectName, 
mainClassQName, deps));
@@ -746,10 +758,20 @@ public class MXMLRoyalePublisher extends JSGoogPublisher 
implements IJSPublisher
         writeFile(new File(targetDir, 
googConfiguration.getHtmlOutputFileName()), htmlFile.toString(), false);
     }
 
-    private void writeCSS(String projectName, File targetDir) throws 
IOException
+    private void writeCSS(String projectName, File targetDir, Boolean minify) 
throws IOException
     {
         JSCSSCompilationSession cssSession = (JSCSSCompilationSession) 
project.getCSSCompilationSession();
-        writeFile(new File(targetDir, projectName + ".css"), 
cssSession.emitCSS(), false);
+        String cssString = cssSession.emitCSS();
+
+        if (minify)
+        {
+            //remove \r\n, \n for now this needs more work at this point
+            cssString = cssString.replaceAll("\\r\\n|\\n", "");
+            writeFile(new File(targetDir, projectName + ".min.css"), 
cssString, false);
+        } else {
+            writeFile(new File(targetDir, projectName + ".css"), cssString, 
false);
+        }
+
         for (CSSFontFace fontFace : cssSession.fontFaces)
         {
                // check frameworks/fonts folder

-- 
To stop receiving notification emails like this one, please contact
carlosrov...@apache.org.

Reply via email to