minify-config is a node.js configuration tool for easily minifying your scripts/stylesheets.
If you still don't have node.js installed, download it at http://nodejs.org/.
If everything went as expected, npm (Node Packaged Modules) was configured with node.js. Verify it typing the following command (in command line):
Considering npm was successfully configured, install the minify-config lib:
npm install -g minify-config
The -g option indicates the lib minify-config will be available for command line usage, if your objective is use the lib as an API this option isn't needed.
To configure the library to minify your application, download the default configuration file or copy it from your npm directory.
The library allows you to compact both your scripts in js extension, as your stylesheets in Less or css extension. You might minify many scripts to a single file, reducing the number of http requests your application requires.
E.g., in the default configuration file,
js/plugins.js js/main.js will be minified to
app.min.js, and stored in the directory defined in
Besides a single file, you may configure minify-config for minifying an entire folder in
folders may receive an Array setting the directories that will be minified, or an regular expression¹.
css.folders allow the use of Glob expressions for parsing your folders.
Minify-config uses Google's htmlcompressor lib for compacting your html. It's required you have Java installed for minifying your templates.
Applying to your Project
To use the library in your project you must place the configuration file on the root of your application (or in the directory that you find more appropriate) with the correct path for the files location.
Now just run the process (command line) making sure to be in the directory where the config.json is stored:
minifyconfig -f config.json
If all paths were set correctly, will be displayed on the screen which processes were executed and which files were generated.
Windows: You may also execute the automin.bat file (copy it from the config folder). This file will automatically execute the command above.
- -h, --help Output usage information
- -V, --version Output the version number
- -f, --file Set the configuration file.
- -s, --stats Show parsed commands in console
- -a, --auto Automatically check for changes and minify configurated files
- -u, --unique Parse configuration and minify a single specified file
Sublime Text 2
It's not required, but Sublime Text editor is highly recommended for improving your development workflow.
Check it out
minify.sublime-snippet set in the config folder.
To make the whole proccess even faster, add the build
Minify.sublime-build on your Sublime. Just set the default build system as Minify (Tools> Build System) and after that perform the build.
It's ready, the command will be processed through command line and your files will be generated.
Comming soon: Sublime Minify Config package
Access lmedeiros.com for more informations.
Copyright (c) 2013 Lucas Medeiros