knyga / kjscompiler

Compiles multiple JavaScript files with Google Closure Compiler application in a right order

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kjscompiler

Makes compilation of multiple JavaScript files with Google Closure Compiler application in right order.

Goal is to convert layout at input:

from

In to minifed layout:

to

With respect to internal and external dependencies.

Requirements

Requires Java Runtime Environment version 7.

How to run

java -jar kjscompiler.jar

Kjscompiler.json

Instead of kjscompile.json you can specify your own path to configuration file with --settings %path% attribute.

basedir - directory or array of directories with JavaScript files;

output - output JavaScript file name;

pattern - rule for filename (*.js);

level - level of optimization (WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS).

wrapper - setting to wrap your output. The place holder is "%output%".

Example:

{
	"basedir": "js",
	"output": "js.min/all.js",
	"level": "SIMPLE_OPTIMIZATIONS",
	"pattern": "*.js"
}

Example:

{
	"basedir": ["lib/javascript", "lib/ecmascript"],
	"output": "js.min/all.js",
	"level": "SIMPLE_OPTIMIZATIONS",
	"pattern": "*.js",
	"wrapper" : "(function(){ %output% }());"
}

Note: Any path will be relative to the settings file. If none provided it will be relative to the current working directory ( the directory where you launched kjscompiler ).

Annotating JavaScript files

Kjscompiler can use information about JavaScript file to build right compiling chain.

Tag Example Description
@depends @depends {somescript.js} Specifies dependency on other file.
@ignore @ignore File with this mark will be ignored.
@external @external File with this mark will be considered as external. It will not be compiled, but it will give no unknown variable error during the compilation.
/**
 * kjscompiler annotation
 * @depends {somescript}
 * @depends {dir/otherscript}
 */
/**
 * kjscompiler annotation
 * @ignore
 */
/**
 * kjscompiler annotation
 * @external
 */

Debug

To debug add --debug true in call line.

Licence

kjscompiler

Copyright (C) 2014 Oleksandr Knyga, oleksandrknyga@gmail.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

About

Compiles multiple JavaScript files with Google Closure Compiler application in a right order

License:MIT License


Languages

Language:Java 66.9%Language:JavaScript 33.1%