edp
edp copied to clipboard
edp webserver stylus 默认配置改进
edp官网对webserver stylus官方配置如下
{
location: /\.styl($|\?)/,
handler: [
file(),
stylus()
]
}
运行edp webserver之后会报错,查看原因是stylus()函数中compileOptions参数没有设置,默认参数也没有,建议stylus默认配置改为如下
{
location: /\.styl($|\?)/,
handler: [
file(),
stylus({
paths: [],
filename: ''
})
]
},
我的方法是直接修改edp-webserver/lib/handlers/stylus.js的源码,加上如下两句:
module.exports = exports = function stylus ( compileOptions, encoding ) {
encoding = encoding || 'utf8';
var defaultCompileOptions = {
paths: [],
filename: ''
};
compileOptions = Object.assign({}, defaultCompileOptions, compileOptions);
return function ( context ) {
var docRoot = context.conf.documentRoot;
var pathname = context.request.pathname;