编译给定文件夹及其子文件夹中的所有手写笔文件

Compiling all stylus files from given folder and its sub-folders

例如编译这个文件夹结构,

x.styl
|--abc/
|--|--a.styl
|--efg/
|--|--b.styl

build/
|--x.css
|--abc/
|--|--a.css
|--efg/
|--|--b.css

使用 stylus 编译器(从文件夹及其子文件夹编译 styl 文件)

您可以在构建和定位整个文件夹时使用 --out 参数,它会保持您的结构,首先您可以定位一个文件或文件夹,然后输出您想要编译的文件夹或文件名 css

stylus -c ./project/stylus --out ./myfolder/css

对于:

|stylus
|--abc/
|--|--a.styl
|--efg/
|--|--b.styl

结果会是这样的:

|css
|--abc/
|--|--a.css
|--efg/
|--|--b.css

我迟到了,但我相信我的解决方案不是最优的,但适合您的情况。

根据您的示例,保持相同的 file/folder 结构

x.styl  
|--abc/  
|--|--a.styl  
|--efg/  
|--|--b.styl

但也在它自己的单独文件夹中包含一个“combination.styl”文件。所以现在你有:

x.styl  
|--abc/  
|--|--a.styl  
|--efg/  
|--|--b.styl  
|--all-stylus/  
|--|--combination.styl

在 combination.styl 中,您应该导入所有单独的 .styl 文件,因此对于我们的示例

// combination.styl  
@import '../x.styl'  
@import '../abc/a.styl'  
//etc...

然后你就可以输出一大css文件到你想要的地方!

运行 的命令就是:

stylus ./stylus -out ./css

我知道它不会为您提供您正在寻找的输出 file/folder 结构,但我认为能够一次将所有手写笔编译成 css 会很有帮助!

有点晚了,我希望这可以帮助其他喜欢它的人帮助我,但我找到了使用包 stylus-chokidar.

的解决方案

stylus-chokidar

Just slightly modified stylus CLI, that builds files list recursively and watches > them with chokidar (if --watch provided).

Recursion are always enabled, glob patterns not supported.

有了这个,您可以就地递归编译手写笔文件(每个组件将存储自己的 CSS/stylus 文件)。