Results 1 to 5 of 5

Thread: How can I get a production build that is still optimized but with original var names?

  1. #1
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default How can I get a production build that is still optimized but with original var names?

    My success rate of been able to modify anything of the default Sencha Cmd production build against an Ext JS application is pretty low. I can find property listed, but if I modify the value these properties, still the output is pretty much always the same, I guess we have dead code in the build script, and dead properties...

    So, let see if we can get some progress with that. I want the exact same production build as the default but instead that all my code variable become one character like:


    Code:
    var a = 'My App Name,
    b = 1234,
    c = 'Important';

    I want to preserve the original variable names and still get the 'other' optimizations, whatever they are.

  2. #2
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    These are among the main optimizations (to change variable names to reduce the file size), together with: removing most this.callParent/callSuper and replace them with the prototypal equivalents, inline functions when possible and removing unecessary characters (e.g. new Date(); -> new Date(); as well as remove all trailing/leading whitespace.

    Based on your other threads in the forum it would look like you'd be just fine by using the development version in production, because that would keep everything just as you have it on development and you've established that file size / load time / number of requests are not really among your concerns.
    Israel Roldán | Senior Software Engineer (Framework tools)

  3. #3
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default

    Quote Originally Posted by israelroldan View Post
    Based on your other threads in the forum it would look like you'd be just fine by using the development version in production, because that would keep everything just as you have it on development and you've established that file size / load time / number of requests are not really among your concerns.
    Hum. You probably mean 'testing' instead of 'development' or you are kidding.

    Again, my question is pretty clear. Are you saying that what I want is not possible at this time?

  4. #4
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    I recall suggesting the usage of the testing build on a previous thread, but you mentioned you didn't want the files to be concatenated and wanted to preserve the original file names and line numbers (if this is an incorrect remark, please accept my apologies).


    In this particular thread, you're asking to preserve the line breaks and original variable names. That would indeed be achieved by using the testing build, because -as mentioned in my previous reply- the intention of building for production is to optimize and minify the code as much as possible.
    Israel Roldán | Senior Software Engineer (Framework tools)

  5. #5
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default

    After too many forum threads inquiries about which parameters I could use to get my build done exactly as needed. I come to the conclusion that most of the Sencha Cmd parameters are dead code due to some hard coding in the XML ANT scripts. So any person that want to keep they sanity should disable Sencha Cmd about calling a compressor, and instead delegate to more flexible framework. Below is what I use in Maven:


    Remove from app.sencha.app.init-impl.xml
    Code:
      <condition property="build.compression" value="-yui">
                <or>
                    <x-is-true value="${build.compression.yui}"/>
                    <equals arg1="yui" arg2="${app.compressor.type}"/>
                </or>
            </condition>
    
    
            <condition property="build.compression" value="-closure">
                <or>
                    <x-is-true value="${build.compression.closure}"/>
                    <equals arg1="closure" arg2="${app.compressor.type}"/>
                </or>
            </condition>
    
    
            <condition property="build.compression" value="-uglify">
                <or>
                    <x-is-true value="${build.compression.uglify}"/>
                    <equals arg1="uglify" arg2="${app.compressor.type}"/>
                </or>
            </condition>

    Change app/.sencha/app/production.defaults.properties:
    Code:
    enable.resource.compression=false
    Maven pom.xml extra steps:
    Code:
    	<plugin>
    				<groupId>com.samaxes.maven</groupId>
    				<artifactId>minify-maven-plugin</artifactId>
    				<version>1.7.4</version>
    				<executions>
    					<execution>
    						<id>default-minify</id>
    						<phase>prepare-package</phase>
    						<!-- When omitted defaults to 'process-resources' -->
    						<configuration>
    							<charset>UTF-8</charset>
    							<webappSourceDir>${basedir}\build\${sencha.env}\OPApp</webappSourceDir>
    							<jsSourceDir>.</jsSourceDir>
    							<jsSourceFiles>
    								<jsSourceFile>app.js</jsSourceFile>
    							</jsSourceFiles>
    							<webappTargetDir>${project.build.directory}</webappTargetDir>
    							<jsFinalFile>app.js</jsFinalFile>
    							<jsEngine>YUI</jsEngine>
    							<yuiNoMunge>true</yuiNoMunge>
    							<verbose>true</verbose>
    						</configuration>
    						<goals>
    							<goal>minify</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    			<plugin>
    				<artifactId>maven-antrun-plugin</artifactId>
    				<version>1.8</version>
    				<executions>
    					<execution>
    						<phase>prepare-package</phase>
    						<configuration>
    							<target>
    								<copy file="${project.build.directory}\app.min.js"
    									tofile="${basedir}\build\${sencha.env}\OPApp\app.js" />
    							</target>
    						</configuration>
    						<goals>
    							<goal>run</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •