Comments (3)
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.
@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.
@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)
- Any way to deal with negative `text-indent`? HOT 2
- Avoid flipping "ltr" or "left" in a data URI HOT 1
- Support flipping mutiple values under a text-shadow or border-shadow rule HOT 2
- Release v1.3.0 HOT 1
- Getting Error "TypeError: cssjanus.transform is not a function" HOT 1
- Translate RegExp's are too relaxed which can result in skipping replacements HOT 1
- How to use this package with "create-react-app" HOT 1
- Request: VS Code extension HOT 1
- Flip transform: scaleX(-1) HOT 2
- end event listener registration error HOT 2
- does not flip when a semicolon is not present at the end of a shorthand rule HOT 3
- Does not flip shorthand properties with expressions in them HOT 3
- The demo is broken HOT 1
- /* @noflip */ doesn't work. HOT 3
- CSSJanus changes right to left in selectors when using the general sibling combinator
- Just wanted to sat thank you HOT 1
- Inconsistent flipping behavior breaks custom CSS properties HOT 1
- Tilde (~) subsequent-sibling combinator causes 'left' in class names to switch to 'right' HOT 2
- License has generic copyright HOT 2
- Flipping for `background` mistakes percentages in color functions for background-position HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-cssjanus.