jjlharrison / gulp-rtlcss

Gulp plugin that uses RTLCSS to convert LTR CSS to RTL.
MIT License
36 stars 7 forks source link

How to use stringMap to replace selectors? #18

Closed meness closed 4 years ago

meness commented 4 years ago

Hi,

return src(['./public/assets/css/**/*.css', '!./public/assets/css/**/*.rtl.css'])
    .pipe(
      rtlcss({
        autoRename: true,
        autoRenameStrict: true,
        blacklist: {},
        clean: true,
        greedy: true,
        processUrls: true,
        stringMap: [
          {
            name: 'left-right',
            priority: 100,
            search: ['left', 'Left', 'LEFT'],
            replace: ['right', 'Right', 'RIGHT'],
            options: {
              scope: '*',
              ignoreCase: true,
            },
          },
          {
            name: 'ltr-rtl',
            priority: 100,
            search: ['ltr', 'Ltr', 'LTR'],
            replace: ['rtl', 'Rtl', 'RTL'],
            options: {
              scope: '*',
              ignoreCase: true,
            },
          },
        ],
        useCalc: true,
      })
    )
    .pipe(rename({ suffix: '.rtl' }))
    .pipe(dest('./public/assets/css'));

It works perfectly with converting CSS properties, but it doesn't replace selectors! How should I use this?

jjlharrison commented 4 years ago

Why do you want to replace the selectors? The whole point of RTLCSS is that you can use the same HTML with a converted CSS file to achieve a RTL version of your site.