MohammadYounes / rtlcss

Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL)
https://rtlcss.com
MIT License
1.68k stars 129 forks source link

Framework does not generate separate file when used as dependency #111

Closed davidluhr closed 6 years ago

davidluhr commented 6 years ago

Hello,

My apologies in advance if I'm misunderstanding the intention of RTLCSS and/or the limitations of PostCSS. When using RTLCSS as a dev dependency in a project, the framework converts all related CSS properties as expected, but simply compiles into a single file, thereby overwriting the input styles needed for production use.

It seems the value of RTLCSS is that it will automatically generate RTL-specific styles to be used if the user's text direction is rtl instead of ltr. With the current implementation, the framework only allows for one compiled file that address the rtl scenario, but does not retain a separate stylesheet for ltr.

Looking through the RTLCSS documentation, I can successfully use the CLI to manually convert a file with a specified output to generate a separate CSS file, but it seems that this is not possible as part of a normal PostCSS workflow. I'm also not seeing options for the output file in the Usage Guide.

Is generating a separate CSS file possible when using RTLCSS as a dependency? Being able to preserve app.css and process it into app.rtl.css as part of an automated workflow would be incredibly valuable.

Thanks in advance for any help, David

MohammadYounes commented 6 years ago

Hello @davidluhr,

In a normal PostCSS workflow, all processors transform the input sequentially one after the other:

Input » Parser » Processor1 » Processor2 » ... » Stringifier » Output

A typical RTLCSS workflow requires a separate task to convert the final LTR output to RTL (in case you want to retain the LTR version):

How to configure such tasks is totally dependent on your build setup. Here is an example of a glup task setup that does this.

Let me know if you need further assistance.

Thanks!

davidluhr commented 6 years ago

@MohammadYounes This is what I suspected, but I wasn't sure because the CLI has such nice functionality. Thank you for the quick response and helpful clarification!

ram33 commented 6 years ago

Hello @MohammadYounes, is there any way to just separate addtional rtl classes to separate file which can be loaded on demand?

PS: we can generate a separate rtl file from ltr, which we are doing currently... but I feel above approach (if possible) makes more sense

MohammadYounes commented 6 years ago

@ram33 I recommend creating a complete RTL version. As for possibility, I think writing a postcss plugin to diff the two versions is a valid option.