Smartcomb: Web module Flattener implemented in PHP, Smartcombweb
Smartcomb is a PHP-implemented Web module Flattener, as opposed to other code flattener tools, such as the following features:
- Any type of file can be flattened, not limited to JS files.
- Centralize and declare dependencies, automatically analyze dependent flattening, and load on demand.
- Supports multiple configuration switches
- Automatically modifies the path of the picture in the css,less without worrying about an error in the CSS picture path after flattening
- Support for PHP command line invocation, support command to generate flattened static files directly
GitHub Address: Https://github.com/hafeyang/smartcomb
Module declaration Configuration
Smartcomb is composed of and composed of smartcomb.php
modules.js
modules.js
a JSON file that must be in strict JSON format, and key needs to be enclosed in double quotes for module declarations. The format is:
{ [profile]:{ "basePath": "所有文件共有的基础路径", "modules":{ "[modulename]":{ [type1]:["file1","file2"], "dependencies":["depend module name","",""] } } } }
Here is a demo:
{ "default":{ "basePath":"modules/", "modules":{ "base":{ "js":["base/base.js","base/common.js"], "css":["base/reset.css"], "less":["base/reset.less"] }, "pageA":{ "js":["pageA/pageA-util.js","pageA/pageA.js"], "css":["pageA/pageA.css"], "dependencies":["base"] } } }}
Used in the Web
The demo above declares the module configuration with the default profile. Declares two module base and Pagea,pagea dependent on the base module. Where the base module consists of two JS files: modules/base/base.js, the path is relative to smartcomb.php
the path, the file type can be arbitrarily defined, using the specified type.
As the above configuration file, we can refer to the following page:
The PageA relies on the base module. Smartcomb automatically flattens dependent files.
smartcomb.php
Call Parameters:
profile
: The configuration type, default defaults. Use this parameter to toggleprofile
type
: File type, type in module declaration, can be any file type that is custom, default is JS
modules
: Modules that need to be flattened, multiple modules can be used, split
Command line using the
You can use PHP commands directly, such as:
php smartcomb.php -profile default -type js -modules pageA
command to output flattening results directly in standard output, you can generate files directly.
php smartcomb.php -profile default -type js -modules pageA > pageA-dep.js
Parameters are consistent with the way web is called
Thanks, any questions, please contact me:)
http://www.bkjia.com/PHPjc/942273.html www.bkjia.com true http://www.bkjia.com/PHPjc/942273.html techarticle Smartcomb: PHP Implementation of the Web module Flattener, Smartcombweb Smartcomb is a PHP implementation of the Web module Flattener, with respect to other code Flattener tool, the following features: can be flattened any ...