Giter Club home page Giter Club logo

Comments (3)

Krinkle avatar Krinkle commented on June 3, 2024

I'm not sure this should be part of the library. It feels like a workaround but a specific downstream use case as you'd never need this inside "normal" code.

With regards to your specific use case, it sounds like you want to optimise time spent inside CSSJanus by sending multiple unrelated stylesheets as one long one string. In ResourceLoader we considered something similar but opted to instead flip and minify individual stylesheets. This allows for more strategic caching and decreases execution time when composing stylesheets or when applying code updates (no need to run filters over unchanged code). Concatenating everything and running filters over it was quite slow at times - and ResourceLoader and CSSJanus are written with on-demand web-execution in mind (no need for builds scripts). For the CSSJanus filter this is not as much of a problem though.

I'd recommend simply running them over individual modules (in parallel or series). Or, if you want to run it only once, perhaps implement some generic function that inserts placeholders for stylesheets you want to exclude and replace them afterwards. Presumably you already have logic in place to determine which stylesheets to exclude (which you planned to honour by dynamically wrapping those in noFlipStart/noFlipEnd while concatenating).

from node-cssjanus.

tomyam1 avatar tomyam1 commented on June 3, 2024

@Krinkle thank you for your input.

I use cssjanus as part of the css build for my app. It is already quite fast, so I rather keep it simple rather than it being fully optimized.

This is my current flow:

For each theme (less file with variable definitions)
     1. Create `ltr.less` that imports all the app less files and the theme files.
     2. Compile that file to `ltr.css` (thus less is doing the actual concatenation)
     3. Create `rtl.css` with cssjanus (not flipping the parts between noFlipStart/noFlipEnd)

Running cssjanus before concatenation would require a more complex flow:

For each theme
     For each component
          1. Create a `componentLtr.less` for import the theme and the component.
          2. Compile it to `componentLtr.css`
          3. Either convert to `componentRtl.css` with cssjanus or just copy it.
     Concatenate all the `componentLtr.css` files to `ltr.css` and the same for rtl.

This is actually how I've done this before, but it became too complicated to coordinate the ordering of the files.

This is the reason I prefer to use noFlipStart/noFlipEnd inside the LESS file rather than choosing which files to run cssjanus on.

Does this seems like a reasonable use case to you?

from node-cssjanus.

Krinkle avatar Krinkle commented on June 3, 2024

@tomyam1 I'm sorry, but I don't believe adding this feature is in the best interest of keeping the library simple and easy to maintain in the future. Adding start/end annotations would make parsing more complicated in the future and requires maintaining state in a way I'd like to avoid.

For more fine-grained control, I recommend flipping individual components instead and concatenating them later on. This also allows for better use of caching and reduced computation time when re-running the workflow after a change was made one or more components.

from node-cssjanus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.