循环使Less会耗尽内存。 (结构优化) [英] Loops make Less to run out of memory. (Structure optimization)

查看:667
本文介绍了循环使Less会耗尽内存。 (结构优化)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个更少的项目,但是开始变得有点大,每次我试图编译我用尽内存。



这是我目前的结构:



  • style.less

  • colors.less

  • icons.less

  • 样式

    • style1

    • style2

    • style3





现在,



  • colors.less是颜色及其类别

  • style.less是主要文件,其中包含和编译所有内容




  • b

    我的问题(实际上是一个建议而不是一个问题)是:


    如何优化这个结构我在尝试编译时不会耗尽内存


    过程如下:



    colors.less icons.less ,图标和类,没有更多。



    我有 colors.less 图标.less 包含在 style1.less style2.less style3.less ,其中我通过颜色创建一个循环。



    最后,我将所有内容导入style.less一个),其中我创建一个循环通过图标,然后添加所有 MIXINS 创建最终结果。问题是我不能编译,因为我用尽了内存。



    我很确定有一些错误在我的结构或任何方式,我可以增加内存(我使用早午餐 - > 官方网站的链接



    任何建议都非常感谢。



    非常感谢。



    信息,只是问。

    解决方案

    部分答案,有办法摆脱循环:颜色和图标数据可以定义为mixins调用,这里是小例子:

      .colors(){
    //array b .-(Maroon,#800000);
    .-(Red,#FF0000);
    .-(Orange,#FFA500);
    .-(Yellow,#FFFF00);
    }

    //生成颜色类:

    .some-prefix {
    .colors();
    .-(@ name,@color){
    &。@ {name} {
    color:contrast(@color);
    background:@color;
    //等
    }
    }
    }

    相同的图标...


    I'm working on a less project, but as is start to become a bit big, every time that i'm trying to compile i run out of memory.

    This is my current structure:

    • style.less
    • colors.less
    • icons.less
    • styles
      • style1
      • style2
      • style3

    Now,

    • colors.less is a list of colors and their classes
    • icons.less a list of icons and their classes
    • style.less is the main file, where all is included and compiled
    • styles is a folder containing all the difference for every different style

    my question (well, actually is more a suggestion than a question) is:

    how can i optimize this structure so that i don't run out of memory anymore when trying to compile?

    The process is the following:

    colors.less and icons.less contains my arrays with color, icons and classes, nothing more.

    I have both colors.less and icons.less included into style1.less,style2.less,style3.less, where i create a loop trough the colors.

    Finally, i'll import everything into style.less (the main one) where i create a loop trough the icons and then add all the MIXINS to create the final result. the problem is that i can't compile as i run out of memory.

    I'm pretty sure that there's something wrong on my structure or any way i can increase the memory (i'm compile using brunch -> this link for official website)

    Any suggestion are really really appreciated.

    Thanks a lot.

    PS: for more information, just ask.

    解决方案

    A partial answer, there's way to get rid of loops: color and icon data can be defined as mixins calls, here's mini example:

    .colors() {
        // "array" of colors
        .-(Maroon, #800000);
        .-(Red,    #FF0000);
        .-(Orange, #FFA500);
        .-(Yellow, #FFFF00);
    }
    
    // generate color classes:
    
    .some-prefix {
        .colors();
        .-(@name, @color) {
            &.@{name} {
                color: contrast(@color);
                background: @color;
                // etc.
            }
        }
    }
    

    Same for icons...

    这篇关于循环使Less会耗尽内存。 (结构优化)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆