3

我使用 csscomb.js 来组织我的 css。它工作得很好,除了我不希望在排序组之间出现换行符。[见图]

有没有办法删除那些?我到处找。

在此处输入图像描述例子

这是 mij 设置:

 "remove-empty-rulesets": false,
    "always-semicolon": true,
    "color-case": "lower",
    "block-indent": "  ",
    "color-shorthand": false,
    "element-case": "lower",
    "leading-zero": true,
    "quotes": "single",
    "sort-order-fallback": "abc",
    "space-before-colon": "",
    "space-after-colon": " ",
    "space-before-combinator": " ",
    "space-after-combinator": " ",
    "space-between-declarations": "\n",
    "space-before-opening-brace": " ",
    "space-after-opening-brace": "\n",
    "space-after-selector-delimiter": "\n",
    "space-before-selector-delimiter": "",
    "space-before-closing-brace": "\n",
    "strip-spaces": false,
    "tab-size": true,
    "unitless-zero": true,
    "vendor-prefix-align": true,
4

2 回答 2

1

没有选择,但这是我使用的一种解决方法。

像这样编辑名为sort-order 的属性:

原来的:

"sort-order": [
        [
            "font",
            "font-family",
            "font-size",
            "font-weight",
            "font-style",
            "font-variant",
            "font-size-adjust",
            "font-stretch",
            "font-effect",
            "font-emphasize",
            "font-emphasize-position",
            "font-emphasize-style",
            "font-smooth",
            "line-height"
        ],
        [
            "position",
            "z-index",
            "top",
            "right",
            "bottom",
            "left"
        ],
        ...

新的:

    "sort-order": [
        [
            "font",
            "font-family",
            "font-size",
            "font-weight",
            "font-style",
            "font-variant",
            "font-size-adjust",
            "font-stretch",
            "font-effect",
            "font-emphasize",
            "font-emphasize-position",
            "font-emphasize-style",
            "font-smooth",
            "line-height",
            "position",
            "z-index",
            "top",
            "right",
            "bottom",
            "left",
            ...
         ]
     ]

基本上,您将组合并为一个,因此不会添加分隔线。这是 Csscomb 创建者的官方回复:github.com/csscomb/csscomb.js/issues/314

于 2016-05-07T16:50:12.043 回答
-1

您可以尝试将插件csscomb-group-size连接到 csscomb,就像寻找答案本身一样......
这里有一点关于开发人员写的内容:

CSScomb - 一个很棒的工具,但有时你想添加任何东西。所以我们试图让代码尽可能地模块化并且易于扩展。您可以添加“梳子”所需的功能,而不用分叉。为此,有以下三种方法:

connect a third-party plug-in
write your plugin
done on the basis of its postprocessor CSScomb

第三方插件

使用别人的插头的最简单方法。例如,这里有一个选项,当组返回太少时,它会删除声明组之间的空白行。连接插件非常简单,use ()方法如下:

var CSScomb = require('csscomb');
var groupSize = require('csscomb-group-size');

 // Number 4 indicates that if the group is less than 4 returns between this
 // And the previous group will remove the empty string delimiter:
var config = { 'group-size': 4 };

// Create a new instance of the "comb":
var csscomb = new CSScomb().use(groupSize).configure(config);

// Works wonders:
csscomb.processPath('path/to/css');  

但是如何让这一切工作,我看不懂,也许,你会详细学习文档并理解。

于 2016-04-12T14:46:09.147 回答