Skip to content

Commit 4dcf6e4

Browse files
committed
add build custom doc
1 parent 34f88be commit 4dcf6e4

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ bower install
2020
npm run build
2121
```
2222

23+
## Build your own modules
24+
25+
https://github.com/kissyteam/kissy/blob/master/build-your-own-modules.md
26+
2327
## Modules
2428

2529
[http://kissyteam.github.io/badgeboard/](http://kissyteam.github.io/badgeboard/)

build-your-own-modules.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# build your own modules
2+
3+
KISSY 5 is a collection of independent modulex modules now, if you do not like all of its modules in KISSY 5,
4+
you can build your own modules, as a bonus, you can control each module's version.
5+
6+
7+
## create bower.json
8+
9+
Create bower.json and fill its ``dependencies`` field with the specified versioned modules you what.
10+
11+
For example: I only want to use loader and anim module
12+
13+
```javascript
14+
{
15+
"name":"my-kissy",
16+
"dependencies": {
17+
"modulex":"1.6.2",
18+
"modulex-anim":"1.0.2"
19+
}
20+
}
21+
```
22+
23+
## create package.json
24+
25+
Require ``aggregate-bower`` modules
26+
27+
For example:
28+
29+
```javascript
30+
{
31+
"name":"my-kissy",
32+
"dependencies": {
33+
"aggregate-bower": "^1.0.9"
34+
}
35+
}
36+
```
37+
38+
## create build.js
39+
40+
Copy https://github.com/kissyteam/kissy/blob/master/build.js to your folder
41+
42+
## build
43+
44+
Run the following command:
45+
46+
```
47+
npm install
48+
bower install
49+
node build
50+
```
51+
52+
The files in ``build/`` folder is what you want, you can load ``build/seed.js`` and use your own custom kissy version.

build.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var buildDir = path.resolve(process.cwd(), 'build');
55
var aggregateBower = require('aggregate-bower');
66
var inferBaseCode = 'modulex.init({name:"seed"});';
77
var kgConfigContent = 'modulex.config({ packages : { kg : { base : "//g.alicdn.com/kg/" }}});';
8-
var extraContent = ['',inferBaseCode,kgConfigContent].join('\n');
8+
var extraContent = ['', inferBaseCode, kgConfigContent].join('\n');
99

1010
function generateSeedJs() {
1111
var seedDebugJsContent = '',
@@ -14,10 +14,11 @@ function generateSeedJs() {
1414
for (var i = 0; i < filesList.length; i++) {
1515
var debugFilePath = path.join(buildDir, filesList[i] + '-debug.js'),
1616
miniFilePath = path.join(buildDir, filesList[i] + '.js');
17-
seedDebugJsContent += fs.readFileSync(debugFilePath).toString();
18-
seedJsContent += fs.readFileSync(miniFilePath).toString();
17+
if (fs.existsSync(debugFilePath)) {
18+
seedDebugJsContent += fs.readFileSync(debugFilePath).toString();
19+
seedJsContent += fs.readFileSync(miniFilePath).toString();
20+
}
1921
}
20-
2122
fs.writeFileSync(path.join(buildDir, 'seed-debug.js'), seedDebugJsContent + extraContent);
2223
fs.writeFileSync(path.join(buildDir, 'seed.js'), seedJsContent + extraContent);
2324
}

0 commit comments

Comments
 (0)