|
| 1 | +# Minification and Deployment |
| 2 | +## Understanding and Using Minification |
| 3 | + |
| 4 | +Enyo comes with a minification tool based on UglifyJS, run by Node.js. |
| 5 | + |
| 6 | +This tool can be used to compress the framework, other libraries, and applications, and will keep load order intact as well as correct url paths in css. |
| 7 | + |
| 8 | +### Why compress? |
| 9 | + |
| 10 | +Compressing enyo apps greatly reduces load times of applications, as well as reducing overall code size. |
| 11 | + |
| 12 | +This way, you can be very verbose in the documentation of your source code, without that impacting the performance of your application in production. |
| 13 | + |
| 14 | +### What is compressed |
| 15 | + |
| 16 | +For enyo, the libraries, and your code: **external assets such as images will not be copied or moved**. |
| 17 | + |
| 18 | +Instead, the CSS url paths are fixed up to reference the new path from the build location. |
| 19 | + |
| 20 | +### How to compress |
| 21 | + |
| 22 | +To compress your application, you must run the Node.js script named `deploy.js` that comes with Enyo, as `enyo/tools/deploy.js`. |
| 23 | + |
| 24 | + $ node enyo/tools/deploy.js -h |
| 25 | + |
| 26 | +This script will run the minification tool located in `enyo/tools/minifier/minify.js`, and make a build of enyo, then a build of your app. |
| 27 | + |
| 28 | +Any libraries referenced in your `package.js` manifest will be built into your app's built code. |
| 29 | + |
| 30 | +**NOTE:** `deploy.js` expects to find a `package.js` in the root-folder of your application. It only references your app's `package.js` to keep paths correct. Do not modify this. |
| 31 | + |
| 32 | +### What comes out? |
| 33 | + |
| 34 | +After running the `deploy.js` script, a new folder `build` (you change this using the `-b` flag of the `deploy.js` script) will be located next to your `source` directory. |
| 35 | + |
| 36 | +In it will be 4 files: |
| 37 | +- enyo.css |
| 38 | +- enyo.js |
| 39 | +- app.css |
| 40 | +- app.js |
| 41 | + |
| 42 | +These files will be loaded in the given order by `index.html`. |
| 43 | + |
| 44 | +The output of the `deploy` scripts will minify your appliaction, and copy the necessary files into `deploy/<appname>/`. |
| 45 | + |
| 46 | +If the libraries have a compatible `deploy.sh` or `deploy.bat` script, they will be executed, and a minimal copy will be placed in the deployment's lib folder. |
| 47 | + |
| 48 | +If no `deploy.(sh|bat)` script is found for the library, all of the library is copied into the lib folder to provide maximum safety. |
| 49 | + |
| 50 | +If you are adding a library, please add a `deploy.sh` file and `deploy.bat` file similar to the ones in `lib/onyx`. |
| 51 | + |
| 52 | +If no images or files are needed from the library, just include blank (and executable) copies of the deploy scripts. |
0 commit comments