-
11 Mar 2013 1:30 PM #1
How to strip all comments from the testing build?
How to strip all comments from the testing build?
I noticed that my testing build app.js file is 1.9Mb, and in the interest of saving bandwidth and loading time I want to strip comments during the build process. I know I can do this with uglifyjs, but how would I integrate this as part of the compilation process?
-
13 Mar 2013 1:57 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
You can create a plugin to hook into the build process
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Mar 2013 1:04 PM #3
Mitchell, that much is obvious. What isn't obvious is how to actually accomplish what I'm after. I've never used Ant in my life, and find Sencha Cmd to be undocumented (and therefore hard to extend).
-
21 Mar 2013 10:49 PM #4
You didn't mention which framework you are using and there are some differences in the details there, but maybe something like this in your app's build.xml would work:
To see the properties in use (and hence things you can control) check out .sencha/app/build-impl.xml.Code:<target name="-after-build"> <x-strip-js srcfile="${build.page.file}" outfile="${build.page.file}"/> </target>
The "-after-build" target is called on the end of "sencha app build" so you can fine tune the results there as needed.
See also http://docs-devel.sencha.com/ext-js/...de/command_ant
For general Ant tasks, see http://ant.apache.org/manual/index.html
If this needs to be only done in testing builds (since x-strip-js may not like the compressed output), you can do this:
Code:<target name="-after-build"> <if> <equals arg1="${args.environment}" arg2="testing"/> <then> <x-strip-js srcfile="${build.page.file}" outfile="${build.page.file}"/> </then> </if> </target>Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
22 Mar 2013 5:52 AM #5
You're right, I did forget to mention that I'm using Sencha Touch 2.1.1 with Sencha Cmd 3.0.2.288.
The code you gave throws an error in ST2.1.1/Cmd3.0.2:
I switched the definition to:Code:[ERR] BUILD FAILED [ERR] java.lang.RuntimeException: $'{'build.page.file'}' (No such file or directory)
I edited because I found a solution. Seems like just listing the source/output as "app.js" won't tell Ant where to find the file.Code:<target name="-after-build"> <if> <equals arg1="${args.environment}" arg2="testing"/> <then> <x-strip-js srcfile="${build.dir}/testing/app.js" outfile="${build.dir}/testing/app.js"/> </then> </if> </target>Last edited by robert_k; 22 Mar 2013 at 5:59 AM. Reason: Found a working solution...
-
22 Mar 2013 11:29 AM #6
I think I missed some properties on x-strip-js sorry. Try this:
You can adjust those three attributes to suite your needs.Code:<x-strip-js srcfile="${build.dir}/testing/app.js" outfile="${build.dir}/testing/app.js" blockcomments="true" linecomments="true" keepfirstcomment="true"/>Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote