1 /** 2 * @fileOverview Declare config info for KISSY. 3 * @author yiminghe@gmail.com 4 */ 5 (function (S) { 6 if (typeof require !== 'undefined') { 7 return; 8 } 9 var Loader = S.Loader, utils = Loader.Utils; 10 /* 11 modify current module path 12 <code> 13 [ 14 [/(.+-)min(.js(\?t=\d+)?)$/,"$1$2"], 15 [/(.+-)min(.js(\?t=\d+)?)$/,function(_,m1,m2){ 16 return m1+m2; 17 }] 18 ] 19 </code> 20 */ 21 S.configs.map = function (rules) { 22 var self = this; 23 return self.Config.mappedRules = (self.Config.mappedRules || []).concat(rules || []); 24 }; 25 26 /* 27 包声明 28 biz -> . 29 表示遇到 biz/x 30 在当前网页路径找 biz/x.js 31 @private 32 */ 33 S.configs.packages = function (cfgs) { 34 var self = this, 35 name, 36 base, 37 Env = self.Env, 38 ps = Env.packages = Env.packages || {}; 39 if (cfgs) { 40 S.each(cfgs, function (cfg, key) { 41 // 兼容数组方式 42 name = cfg.name || key; 43 // 兼容 path 44 base = cfg.base || cfg.path; 45 46 // 注意正则化 47 cfg.name = name; 48 cfg.base = base && utils.normalBasePath(base); 49 cfg.SS = S; 50 delete cfg.path; 51 52 ps[ name ] = new Loader.Package(cfg); 53 }); 54 } 55 }; 56 57 /* 58 只用来指定模块依赖信息. 59 <code> 60 61 KISSY.config({ 62 base:'', 63 // dom-min.js 64 debug:'', 65 combine:true, 66 tag:'', 67 packages:{ 68 "biz1": { 69 // path change to base 70 base: "haha", 71 // x.js 72 debug:'', 73 tag:'', 74 combine:false, 75 } 76 }, 77 modules:{ 78 "biz1/main" : { 79 requires: [ "biz1/part1" , "biz1/part2" ] 80 } 81 } 82 }); 83 */ 84 S.configs.modules = function (modules) { 85 var self = this; 86 if (modules) { 87 S.each(modules, function (modCfg, modName) { 88 modName = utils.indexMapStr(modName); 89 utils.createModuleInfo(self, modName, modCfg); 90 S.mix(self.Env.mods[modName], modCfg); 91 }); 92 } 93 }; 94 95 S.configs.modules.order = 10; 96 97 /* 98 KISSY 's base path. 99 */ 100 S.configs.base = function (base) { 101 var self = this; 102 if (!base) { 103 return self.Config.base; 104 } 105 self.Config.base = utils.normalBasePath(base); 106 }; 107 })(KISSY);