Smartcomb: Web module Flattener implemented in PHP, smartcombweb_php tutorial

Source: Internet
Author: User

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.phpCall 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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.