项目作者: andreatulimiero

项目描述 :
Simple JS closure compiler that communicates with Google Closure Compiler Service
高级语言: Python
项目地址: git://github.com/andreatulimiero/js_closure_compiler_in_python.git
创建时间: 2016-10-15T11:32:39Z
项目社区:https://github.com/andreatulimiero/js_closure_compiler_in_python

开源协议:MIT License

下载


JS closure compiler in Python

Simple JS closure compiler written in Python that communicates with Google Closure Compiler Service.

Compile a JS file with closure not only reduces the size of the specified files, that is critical in the creation of a modern site, but also ensure
full compatibility with older sites that don’t support the new ECMASCRIPT2016, giving you the possibility to use all of its sugar features.

All you need to do is specify a list of the files you want to be compiled

Usage

Put the closure_compiler.py wherever you want and add all the files you want to compile in the .to_closure_compile file,
one line per file - relative paths are allowed as well.

Example:

Project’s folder structure
  1. index.html
  2. js/
  3. ├─closure_compiler.py
  4. ├─elements/
  5. ├─topbar.js
  6. ├─config.js
  7. ├─app.js
.to_closure_compile file structure
  1. elements/topbar.js
  2. config.js
  3. app.js

Configuration

Configuration file

The compiler can be customized to suit your needs.

The configuration is a json dictionary file, it has to be called .closure_compiler_congif.json.

However, if no config file it’s specified, the default values will be used instead

Configuration file structure (below are the default values):

  1. {
  2. "url" : "http://closure-compiler.appspot.com/compile",
  3. "compilation_level" : "WHITESPACE_ONLY",
  4. "output_format" : "text",
  5. "output_info" : "compiled_code",
  6. "output_file" : "app.min.js"
  7. }

Configuration options


url

This field shouldn’t not be changed, but in case google will change the url, you can specify yours

compilation_level


This is the optimization level you want to use. Possible options are WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS and ADVANCED_OPTIONS

output_format

This is the format that the server will use to return the file. Possible formats are text, xml and json

output_info


This parameter indicates what kind of information the server should return. Possible infos are compiled_code, warnings,
errors and statistics

output_file

Specify the name of the file you want the compiled_code, or any other information, to be saved


Other informations can be found directly in the Google’s site

Requirements

Python 3

Python’s package requests, you can install it with pip
using the requirements.txt file with:

  1. pip install -r requirements.txt