kef-kit-buffet
Version:
buffet kit
42 lines (36 loc) • 1.06 kB
JavaScript
;
module.exports = function (Kit, def) {
return {
description: 'buffet开始编译页面',
options: {
entryPage: {
alias: 't',
description: '页面筛选,例如 -t=index,选择只编译 index 页面'
}
},
handler: function* (args, kwargs) {
let abcOptions = def.lookupABCJson();
let builder = abcOptions.builder;
// 环境变量 这里还要分日常 预发 生产的 所以不能简单这么写,找个地方定义常量
process.env.NODE_ENV = 'production';
let style = '';
// 定义样式后缀
if (abcOptions.options.style === 'postcss') {
// process.env.BUILD_STYLE_EXTENSION = '.pcss';
style = '--style=.pcss';
} else {
// process.env.BUILD_STYLE_EXTENSION = '.scss';
style = '--style=.scss';
}
try {
// 调用 def build
yield def.kit.build.run({
builder: builder,
argv: [style]
});
} catch (e) {
def.log.error(e);
}
}
};
};