2

Is it possible to make App Engine automatically minify certain javascript and css files upon deployment, just like Jinja2 automatically compiles templates for you? I've seen some Python scripts that do minification, but how do I integrate them with webapp2?

I'm using the latest Google App Engine version with Python 2.7.

1 Answer 1

3

You can write a simple script to do so.

# -- update_batch.py --
import sys
import os

def main():
    if len(sys.argv) == 1:
        return 

    appId = sys.argv[1]
    print "appId", appId

    # Your script to minify javascipt
    #os.chdir(r".\template")
    #cmd = r'jscom.py ./js/new/xxx_plugin.js xxx_plugin.js %s.appspot.com'%appId
    #os.system(cmd)

    os.chdir("..")
    # Perform appcfg.py to update GAE server
    cmd = r'"C:\Program Files\Google\google_appengine\appcfg.py"'
    os.system(cmd + " update . " + " -A %s"%appId)

    #os.system(cmd + " backends . " + " update worker " + " -A %s"%appId)

if __name__ == "__main__":
    main()

# Usage update_batch.py YOUR_APP_ID_HERE
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer! Would it be possible to hook a script like this directly into a webapp2 app so I don't have to call a separate script for deployment but can deploy as I normally would using the Google App Engine Launcher?
@Aneon This has nothing to do with the webapp framework you use - that's not involved in the deploy process in any way. And no, there's no way to run a pre-deploy script from appcfg.
Ah, I assumed Jinja2 ran a pre-compile script for its templates, but I guess it's done some other way. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.