handlino/FireApp — pull request #159 by Aaron3 (2013-06-28 10:57:44+00:00)
Title: Minify on save or compile. (Cleaned up. Fully configurable and optional.)

Hopefully, this pull request addresses your concerns with usefulness along with minify on build. This is fully cleaned up aside from the readme file (adapted for my fork), it can be pulled into the main branch.

## Why This is Useful Along with Minify on Build

1. Building breaks Git version control. (We use git to host and push to production all of our projects.)
* Build encourages committing completed branches rather than a branch with many smaller commits.

1. When pushing, branching, code reviewing and deploying projects from git, the .js and .min.js are always the same version, so QA can test both the development environment and pre-production environment at the same time from the same pull.

1. On rapid iteration projects, you may push and deploy only a few lines of changes.

1. When building, all files have their date-stamps modified not just changed files. This can create confusion on what exact files were changed.

1. Not all projects fit with the standard build setup examples: Wordpress themes or plugins, most smaller PHP-based projects, projects where only a single section requires fire.app, projects with multiple coders working on different sections, github hosted projects.

## Features and Changes

1. Can use configuration options to set minified folder name.

1. Can be enabled and disabled in project options panel.
* *Minify On Clean & Compile*: defaults to true;
* *Minify On Save*: defaults to false;

1. Watches all .js files in _javascripts\_dir_ folder recursively for changes and saves the uglified versions as filename.min.js to the folder _javascripts\_min\_dir_.

1. Works with Clean & Compile (If you disable minify\_on\_clean, it will delete the _javascripts\_min\_dir_ folder and not recreate it.)

1. Works with both LiveReload and coffeescript generated files.

1. Handles deleting .min.js files when .js files are deleted.

1. If you manually save a .min.js in your _javascripts\_dir_ directory, it will create a minified version of it in your _javascripts\_min\_dir_ folder, but will not change the extension to ".min.min.js".

**Your _javascripts\_dir_ folder and your _javascripts\_min\_dir_ folder can be at different levels** so you can set up a directory structure like:

```
/main folder
/assets
/js (note: minified files)
/css
/images
/library
/coffee
/js
/scss
```

## Issues:

1. If your main /js/ folder contains "jquery.min.js" and "jquery.js" and you delete "jquery.min.js" it will also delete "/js-min/jquery.min.js". (Rare case when migrating to using minify, a manual clean and compile should be used instead)

## Questions

1. If in your source js folder you have a .min.js, should it be directly copied to js_min folder instead of minified again with the same name?