Created
December 22, 2015 04:22
-
-
Save eavae/509cdb05082edccefd78 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* @file build配置 | |
* @author edpx-mobile | |
*/ | |
var cwd = process.cwd(); | |
var path = require('path'); | |
// 引入 rider 支持 | |
var epr = require('./edp-rider-config'); | |
/** | |
* 指定匹配版本的 stylus | |
*/ | |
exports.stylus = epr.stylus; | |
/** | |
* 输入目录 | |
* | |
* @type {string} | |
*/ | |
exports.input = cwd; | |
/** | |
* 输出目录 | |
* | |
* @type {string} | |
*/ | |
exports.output = path.resolve(cwd, 'output'); | |
/** | |
* 排除文件pattern列表 | |
* | |
* @type {Array} | |
*/ | |
exports.exclude = [ | |
'tool', | |
'doc', | |
'test', | |
'module.conf', | |
'dep/packages.manifest', | |
'dep/*/*/test', | |
'dep/*/*/doc', | |
'dep/*/*/demo', | |
'dep/*/*/tool', | |
'dep/*/*/*.md', | |
'dep/*/*/package.json', | |
'edp-*', | |
'node_modules', | |
'.edpproj', | |
'.svn', | |
'.git', | |
'.gitignore', | |
'.idea', | |
'.project', | |
'Desktop.ini', | |
'Thumbs.db', | |
'.DS_Store', | |
'*.tmp', | |
'*.bak', | |
'*.swp', | |
'.fecsrc', | |
'.fecsignore', | |
'mock', | |
'test', | |
'.editorconfig', | |
'nav-test.html', | |
'README', | |
'package.json', | |
'build', | |
'*.tpl.demo', | |
'html' | |
]; | |
/** | |
* 获取构建processors的方法 | |
* | |
* @return {Array} | |
*/ | |
exports.getProcessors = function () { | |
var cssProcessor = new CssCompressor(); | |
var jsProcessor = new JsCompressor(); | |
var pathMapperProcessor = new PathMapper(); | |
var html2jsPorcessor = new Html2JsCompiler({ | |
extnames: 'tpl', | |
combine: true | |
}); | |
var html2jsClearPorcessor = new Html2JsCompiler({ | |
extnames: 'tpl', | |
clean: true | |
}); | |
var stylusProcessor = new StylusCompiler({ | |
stylus: epr.stylus, | |
compileOptions: { | |
use: epr.stylusPlugin | |
} | |
}); | |
var combineEntry = require('combine-entry'); | |
var moduleCompiler = new ModuleCompiler( | |
combineEntry('entry/**/*.html', {moduleId: 'common/boot'}) | |
); | |
var md5renamer = new MD5Renamer({ | |
files: [ | |
'src/food/index.js', | |
], | |
replacements: { | |
html: [ | |
'entry/*.html' | |
], | |
css: [ | |
'src/**/*.css' | |
] | |
}, | |
outputTemplate: '{basename}-{md5sum}{extname}', | |
start: 1, | |
end: 12 | |
}); | |
return { | |
'default': [ | |
stylusProcessor, | |
cssProcessor, | |
html2jsPorcessor, | |
moduleCompiler, | |
html2jsClearPorcessor, | |
pathMapperProcessor | |
], | |
'release': [ | |
stylusProcessor, | |
cssProcessor, | |
html2jsPorcessor, | |
moduleCompiler, | |
html2jsClearPorcessor, | |
jsProcessor, | |
md5renamer, | |
pathMapperProcessor | |
] | |
}; | |
}; | |
// exports.moduleEntries = 'html,htm,phtml,tpl,vm,js'; | |
// exports.pageEntries = 'html,htm,phtml,tpl,vm'; | |
/** | |
* builder主模块注入processor构造器的方法 | |
* | |
* @param {Object} processors | |
*/ | |
exports.injectProcessor = function (processors) { | |
for (var key in processors) { | |
global[ key ] = processors[ key ]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment