node-kpc

build KISSY packages

KPC

Build a KISSY package, for KISSY 1.3+.

  • Simple
  • KISSY 1.3+
  • Online combo only
  • Support CJS Style
  • Support Module Name Flatten
  • Support KISSY.add auto generate for no-kissy module

This module is installed via npm:

$ npm install node-kpc
  • options.name, String, Name of package, required
  • options.path, String, Path of package, required
  • options.flatten, Boolean, false, 是否压缩模块名, optional
  • files Array|String, Files to compile, optional
  • options.name, String, Name of package, required
  • options.path, String, Path of package, required
  • options.flatten, Boolean, false, 是否压缩模块名, optional
  • files Array|String, Files to compile, optional
  • Return Object
  • modules Object, the module object compiled
  • return String
var kpc = require('node-kpc');
 
// build a package 
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to 
    depFile: 'sample/build/map.js'
});
 
Before After
sample/src
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└── pages
    └── home
        ├── index.js
        └── mod.js
sample/build
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
├── map.js
└── pages
    └── home
        ├── index.js
        └── mod.js
var kpc = require('node-kpc');
 
// build a package 
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to 
    depFile: 'sample/build/map.js' // 
}, ['sample/src/app/*.js']);
 

After build:

src dest
sample/src
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└── pages
    └── home
        ├── index.js
        └── mod.js
sample/build
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└─ map.js
var kpc = require('node-kpc');
 
var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
});
 
console.log(pkg);
 
```
 
the pkg look like this
 
```json
{
    "files": [
        {
            "srcCode": "/**\n * @fi...",
            "isKISSY": true,
            "modules": [
                {
                    "name": "xcake/app/cjs",
                    "requires": [
                        "node",
                        "../components/header/",
                        "./mod/",
                        "./example.css"
                    ]
                }
            ],
            "genCode": "/**\n * @fi...",
            "filename": "app/cjs.js",
            "srcFile": "sample/src/app/cjs.js"
        }
    ],
    "ignoredFiles": [],
    "modules": {
        "xcake/app/cjs": {
            "requires": [
                "node",
                "../components/header/",
                "./mod/",
                "./example.css"
            ]
        }
    }
}
```
 
#### Case5. Specify files to compile
 
````js
var kpc = require('node-kpc');
 
var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
}, ['sample/src/app/*']);
 
console.log(pkg);
 
```