Last active
August 29, 2015 13:57
-
-
Save leeight/9914869 to your computer and use it in GitHub Desktop.
app/ecom/fe/trunk/vs/bs-edu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.gitignore b/.gitignore | |
new file mode 100644 | |
index 0000000..53752db | |
--- /dev/null | |
+++ b/.gitignore | |
@@ -0,0 +1 @@ | |
+output | |
diff --git a/edp-build-config.js b/edp-build-config.js | |
index e936926..6d3466c 100644 | |
--- a/edp-build-config.js | |
+++ b/edp-build-config.js | |
@@ -3,158 +3,62 @@ exports.input = __dirname; | |
var path = require('path'); | |
exports.output = path.resolve(__dirname, 'output'); | |
-var moduleEntries = 'html,htm,phtml,tpl,vm,js'; | |
-var pageEntries = 'html,htm,phtml,tpl,vm'; | |
-exports.getProcessors = function () { | |
- var ModuleCompiler = require('./tool/ModuleCompiler'); | |
- var Versioning = require('./tool/Versioning'); | |
- | |
- // JS压缩处理器占位符 | |
- var JS_COMPRESSOR = 'JSCompressor'; | |
- | |
- var processors = [ | |
- new LessCompiler({ | |
- entryExtnames: pageEntries, | |
- exclude: ['*.less'], | |
- include: [ | |
- 'src/common/css/main.less', | |
- 'dep/font-awesome/3.1.0/less/font-awesome.less', | |
- 'dep/font-awesome/3.1.0/less/font-awesome-ie7.less', | |
- 'dep/esui/3.0.1/src/css/main.less' | |
- ] | |
- }), | |
- new CssCompressor(), | |
- new ModuleCompiler({ | |
- exclude: [ | |
- 'dep/swfupload/2.2.0/plugins/*.js' | |
- ], | |
- include: [ | |
- 'dep/swfupload/2.2.0/plugins/swfupload.cookies.js' | |
- ], | |
- toCombineModules: [ | |
- | |
- // 对依赖的外部基础库/框架进行合并 | |
- ['main', { | |
- exclude: ['common/util'] | |
- }], | |
- | |
- // 对项目公共工具方法及业务代码进行合并 | |
- // 注意不要include包含有Actin/View等子类的文件,见上述main.js里说明, | |
- // 由于框架代码被修改了 | |
- ['common/util', { | |
- include: [ | |
- 'common/logger', | |
- 'common/util/sorter', | |
- 'common/util/position', | |
- 'common/biz/bizUtil', | |
- 'common/biz/keywordUtil', | |
- 'common/biz/unitUtil', | |
- 'common/biz/ideaUtil', | |
- 'common/biz/regionUtil', | |
- 'common/config/city', | |
- 'common/config/event', | |
- 'common/config/noun', | |
- 'common/config/regexp', | |
- 'common/config/status', | |
- 'common/config/table', | |
- 'common/config/globalConf', | |
- 'common/tplList', | |
- 'common/locales/strings', | |
- 'common/ui/UIHelper', | |
- 'common/ui/DialogFactory', | |
- 'common/ui/TableInlineEdit' | |
- ] | |
- }], | |
- // 对入口业务模块进行合并 | |
- ['index/main', { | |
- include: [ | |
- 'account/index/info/Action', | |
- 'index/header/HeaderAction', | |
- 'index/entry/EntryAction', | |
- 'index/levelIndex/Action', | |
- 'index/levelIndex/crumb/Action', | |
- 'index/levelIndex/filter/MaterialQueryView', | |
- 'index/levelIndex/sum/MaterialSumView', | |
- 'index/levelIndex/tabs/Action', | |
- 'common/biz/dataTable/Action', | |
- 'common/biz/dataTable/Model', | |
- 'common/biz/dataTable/View' | |
- ] | |
- }], | |
- | |
- // 其它按需加载模块的合并 | |
- ['plan/list/Action'], | |
- ['unit/list/Action'], | |
- ['idea/list/Action'], | |
- ['keyword/list/Action'], | |
- ['reservation/index/ReservationAction'] | |
- ], | |
- configFile: 'module.conf', | |
- entryExtnames: moduleEntries | |
- }), | |
- new TplMerge({ | |
- pluginIds: [ 'er/tpl' ] | |
- }), | |
- JS_COMPRESSOR, | |
- new Versioning({ | |
- cssFilePaths: ['src/common/css/main.less'], | |
- pathPrefixDepth: 2, | |
- output: '\'esl_resource_version\'' | |
- }), | |
- new PathMapper({ | |
- replacements: [ | |
- { type: 'html', tag: 'link', attribute: 'href', extnames: pageEntries }, | |
- { type: 'html', tag: 'img', attribute: 'src', extnames: pageEntries }, | |
- { type: 'html', tag: 'script', attribute: 'src', extnames: pageEntries }, | |
- { extnames: moduleEntries, replacer: 'module-config' }//, | |
- //{ extnames: 'css,less', replacer: 'css' }// TODO 后续新版edp 发布再开启 | |
- ], | |
- from: 'src', | |
- to: 'asset' | |
- }) | |
- ]; | |
- | |
- // 如果是输出到发布目录,开启JS压缩,否则暂时移除压缩功能 | |
- var isRelease = /release$/.test(this.output); | |
- console.log('output dir: ' + this.output); | |
- var idx = processors.indexOf(JS_COMPRESSOR); | |
- if (isRelease) { | |
- console.log('Enabel JSCompressor......'); | |
- processors[idx] = new JsCompressor({ | |
- compressOptions: { | |
- warnings: false // 关闭警告信息输出 | |
- } | |
- }); | |
- } | |
- else { | |
- console.log('Disable JSCompressor......'); | |
- processors.splice(idx, 1); | |
- } | |
+exports.getProcessors = function () { | |
+ var less = new LessCompiler({ | |
+ files: [ | |
+ 'src/common/css/main.less', | |
+ 'dep/font-awesome/*/less/font-awesome.less', | |
+ 'dep/font-awesome/*/less/font-awesome-ie7.less', | |
+ 'dep/esui/*/src/css/main.less' | |
+ ], | |
+ pageFiles: [ | |
+ 'index.html' | |
+ ] | |
+ }); | |
+ var css = new CssCompressor(); | |
+ var module = new ModuleCompiler({ | |
+ files: [ | |
+ '*.js', | |
+ '!**/swfupload/*/plugins/**' | |
+ ], | |
+ getCombineConfig: require( './tool/get-combine-config' ) | |
+ }); | |
+ var tplMerger = new TplMerge({ | |
+ files: [ | |
+ 'src/**/*.js' | |
+ ], | |
+ pluginIds: [ 'er/tpl' ] | |
+ }); | |
+ var pathMapper = new PathMapper(); | |
- return processors; | |
+ return { | |
+ 'default': [ | |
+ less, module, tplMerger, pathMapper | |
+ ] | |
+ }; | |
}; | |
exports.exclude = [ | |
- '/tool', | |
- '/doc', | |
- '/test', | |
- '/mock', | |
- '/output', | |
- '/release', | |
- '/src/mock.js', | |
- '/src/common/readme.txt', | |
- '/module.conf', | |
- '/dep/packages.manifest', | |
- '/dep/*/*/test', | |
- '/dep/*/*/doc', | |
- '/dep/*/*/demo', | |
- '/dep/*/*/tool', | |
- '/dep/*/*/*.md', | |
- '/dep/*/*/package.json', | |
- '/edp-*', | |
- '/.edpproj', | |
+ 'tool', | |
+ 'doc', | |
+ 'test', | |
+ 'mock', | |
+ 'output', | |
+ 'release', | |
+ 'src/mock.js', | |
+ 'src/common/readme.txt', | |
+ 'module.conf', | |
+ 'dep/packages.manifest', | |
+ 'dep/*/*/test', | |
+ 'dep/*/*/doc', | |
+ 'dep/*/*/demo', | |
+ 'dep/*/*/tool', | |
+ 'dep/*/*/*.md', | |
+ 'dep/*/*/package.json', | |
+ 'edp-*', | |
+ '.edpproj', | |
'.svn', | |
'.git', | |
'.gitignore', | |
diff --git a/edp-webserver-config.js b/edp-webserver-config.js | |
index b07a66a..7ef8df8 100644 | |
--- a/edp-webserver-config.js | |
+++ b/edp-webserver-config.js | |
@@ -43,7 +43,7 @@ function loadReqMockObj(request) { | |
return require(mockModuleName); | |
} | |
catch (e) { | |
- console.log('Not Mock Path: '.red + path.red); | |
+ console.log('Not Mock Path: ' + path); | |
return null; | |
} | |
} | |
@@ -139,7 +139,7 @@ exports.getLocations = function () { | |
} | |
catch (e) { | |
context.status = 500; | |
- console.log("Save Upload Img Error: ".red + e.toString()); | |
+ console.log("Save Upload Img Error: " + e.toString()); | |
} | |
} | |
] | |
@@ -170,7 +170,7 @@ exports.getLocations = function () { | |
var request = context.request; | |
var query = qs.parse(request.search.substr(1)); | |
- console.log('process jsonp request: '.green + request.path); | |
+ console.log('process jsonp request: ' + request.path); | |
var callbackFuncName = query[JSONP_CALLBACK_KEY]; | |
var mockPath = './mock/jsonp/jsonp'; | |
@@ -198,7 +198,7 @@ exports.getLocations = function () { | |
} | |
catch (e) { | |
context.status = 500; | |
- console.log('\nError Happen: '.red + e.toString().red + '\n'); | |
+ console.log('\nError Happen: ' + e.toString() + '\n'); | |
context.start(); | |
} | |
} | |
@@ -276,7 +276,7 @@ exports.getLocations = function () { | |
} | |
catch (e) { | |
context.status = 500; | |
- console.log('\nError Happen: '.red + e.toString().red + '\n'); | |
+ console.log('\nError Happen: ' + e.toString() + '\n'); | |
context.start(); | |
} | |
} | |
diff --git a/index.html b/index.html | |
index 0d3852f..ef1caf1 100644 | |
--- a/index.html | |
+++ b/index.html | |
@@ -110,7 +110,6 @@ | |
}); | |
require([ 'main' ]); | |
- | |
</script> | |
</body> | |
diff --git a/module.conf b/module.conf | |
index 93aa670..bf32a0d 100644 | |
--- a/module.conf | |
+++ b/module.conf | |
@@ -4,56 +4,53 @@ | |
"packages": [ | |
{ | |
"name": "er", | |
- "location": "dep/er/3.0.2/src", | |
+ "location": "../dep/er/3.0.2/src", | |
"main": "main" | |
}, | |
{ | |
"name": "esui", | |
- "location": "dep/esui/3.0.1/src", | |
+ "location": "../dep/esui/3.0.1/src", | |
"main": "main" | |
}, | |
{ | |
"name": "ef", | |
- "location": "dep/ef/3.0.1/src", | |
+ "location": "../dep/ef/3.0.1/src", | |
"main": "main" | |
}, | |
{ | |
"name": "moment", | |
- "location": "dep/moment/2.0.0/src", | |
+ "location": "../dep/moment/2.0.0/src", | |
"main": "moment" | |
}, | |
{ | |
"name": "underscore", | |
- "location": "dep/underscore/1.4.4/src", | |
+ "location": "../dep/underscore/1.4.4/src", | |
"main": "underscore" | |
}, | |
{ | |
"name": "underscore.string", | |
- "location": "dep/underscore.string/2.3.1/src", | |
+ "location": "../dep/underscore.string/2.3.1/src", | |
"main": "underscore.string" | |
}, | |
{ | |
"name": "swfupload", | |
- "location": "dep/swfupload/2.2.0", | |
+ "location": "../dep/swfupload/2.2.0", | |
"main": "swfupload" | |
}, | |
{ | |
"name": "imagecrop", | |
- "location": "dep/imagecrop/0.0.2/src", | |
+ "location": "../dep/imagecrop/0.0.2/src", | |
"main": "imagecrop" | |
}, | |
{ | |
"name": "json2", | |
- "location": "dep/json2/1.0.1/src", | |
+ "location": "../dep/json2/1.0.1/src", | |
"main": "json2" | |
}, | |
{ | |
"name": "store", | |
- "location": "dep/store/1.3.15/src", | |
+ "location": "../dep/store/1.3.15/src", | |
"main": "store" | |
} | |
- ], | |
- "combine": { | |
- "main": 1 | |
- } | |
-} | |
\ No newline at end of file | |
+ ] | |
+} | |
diff --git a/src/startup/ria.js b/src/startup/ria.js | |
new file mode 100644 | |
index 0000000..1646a20 | |
--- /dev/null | |
+++ b/src/startup/ria.js | |
@@ -0,0 +1,38 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * src/startup/ria.js ~ 2014/04/01 22:01:42 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+define({}); | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ | |
diff --git a/tool/get-combine-config.js b/tool/get-combine-config.js | |
new file mode 100644 | |
index 0000000..7882b6a | |
--- /dev/null | |
+++ b/tool/get-combine-config.js | |
@@ -0,0 +1,109 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * tool/get-combine-config.js ~ 2014/04/01 21:42:43 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+ | |
+function negative( array ) { | |
+ return array.map(function( item ){ return '!' + item; }); | |
+} | |
+ | |
+module.exports = function() { | |
+ var cfg = {}; | |
+ | |
+ // TODO(user) 更加精细化的模块依赖配置 | |
+ | |
+ var ria = [ | |
+ '~esui', | |
+ '~er', | |
+ '~ef', | |
+ 'json2', | |
+ 'store', | |
+ 'swfupload', | |
+ 'moment', | |
+ 'underscore', | |
+ 'underscore.string' | |
+ ]; | |
+ | |
+ var util = [ | |
+ 'common/logger', | |
+ '~common/util', | |
+ 'common/biz/*Util', | |
+ '~common/config', | |
+ 'common/tplList', | |
+ 'common/locales/strings', | |
+ 'common/ui/UIHelper', | |
+ 'common/ui/DialogFactory', | |
+ 'common/ui/TableInlineEdit', | |
+ '~common/service', | |
+ '~common/datasource' | |
+ ]; | |
+ | |
+ var indexAction = [ | |
+ 'account/index/info/Action', | |
+ 'index/header/HeaderAction', | |
+ 'index/entry/EntryAction', | |
+ 'index/levelIndex/Action', | |
+ 'index/levelIndex/crumb/Action', | |
+ 'index/levelIndex/filter/MaterialQueryView', | |
+ 'index/levelIndex/sum/MaterialSumView', | |
+ 'index/levelIndex/tabs/Action', | |
+ 'common/biz/dataTable/Action', | |
+ 'common/biz/dataTable/Model', | |
+ 'common/biz/dataTable/View' | |
+ ]; | |
+ | |
+ // 加载顺序 | |
+ // main | |
+ // common/util | |
+ // -> index/main | |
+ // -> Action1 | |
+ // -> Action2 | |
+ // -> Action3 | |
+ | |
+ cfg[ 'main' ] = { | |
+ files: [ ria, negative( util ) ] | |
+ }; | |
+ | |
+ cfg[ 'common/util' ] = { | |
+ files: [ util, negative( ria ), '!report/reportConf' ] | |
+ }; | |
+ | |
+ cfg[ 'index/main' ] = { | |
+ files: [ indexAction, negative( util ), negative( ria ) ] | |
+ }; | |
+ | |
+ return cfg; | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment