Skip to content

edp webserver stylus 默认配置改进 #358

@zhanfang

Description

@zhanfang

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions