Skip to content

Commit

Permalink
add build custom doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Nov 6, 2014
1 parent 34f88be commit 4dcf6e4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ bower install
npm run build
```

## Build your own modules

https://github.com/kissyteam/kissy/blob/master/build-your-own-modules.md

## Modules

[http://kissyteam.github.io/badgeboard/](http://kissyteam.github.io/badgeboard/)
Expand Down
52 changes: 52 additions & 0 deletions build-your-own-modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# build your own modules

KISSY 5 is a collection of independent modulex modules now, if you do not like all of its modules in KISSY 5,
you can build your own modules, as a bonus, you can control each module's version.


## create bower.json

Create bower.json and fill its ``dependencies`` field with the specified versioned modules you what.

For example: I only want to use loader and anim module

```javascript
{
"name":"my-kissy",
"dependencies": {
"modulex":"1.6.2",
"modulex-anim":"1.0.2"
}
}
```

## create package.json

Require ``aggregate-bower`` modules

For example:

```javascript
{
"name":"my-kissy",
"dependencies": {
"aggregate-bower": "^1.0.9"
}
}
```

## create build.js

Copy https://github.com/kissyteam/kissy/blob/master/build.js to your folder

## build

Run the following command:

```
npm install
bower install
node build
```

The files in ``build/`` folder is what you want, you can load ``build/seed.js`` and use your own custom kissy version.
9 changes: 5 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var buildDir = path.resolve(process.cwd(), 'build');
var aggregateBower = require('aggregate-bower');
var inferBaseCode = 'modulex.init({name:"seed"});';
var kgConfigContent = 'modulex.config({ packages : { kg : { base : "//g.alicdn.com/kg/" }}});';
var extraContent = ['',inferBaseCode,kgConfigContent].join('\n');
var extraContent = ['', inferBaseCode, kgConfigContent].join('\n');

function generateSeedJs() {
var seedDebugJsContent = '',
Expand All @@ -14,10 +14,11 @@ function generateSeedJs() {
for (var i = 0; i < filesList.length; i++) {
var debugFilePath = path.join(buildDir, filesList[i] + '-debug.js'),
miniFilePath = path.join(buildDir, filesList[i] + '.js');
seedDebugJsContent += fs.readFileSync(debugFilePath).toString();
seedJsContent += fs.readFileSync(miniFilePath).toString();
if (fs.existsSync(debugFilePath)) {
seedDebugJsContent += fs.readFileSync(debugFilePath).toString();
seedJsContent += fs.readFileSync(miniFilePath).toString();
}
}

fs.writeFileSync(path.join(buildDir, 'seed-debug.js'), seedDebugJsContent + extraContent);
fs.writeFileSync(path.join(buildDir, 'seed.js'), seedJsContent + extraContent);
}
Expand Down

0 comments on commit 4dcf6e4

Please sign in to comment.