Override theme to use custom css file in rtl support

We require rtl support for showing content in language supporting right to left text (Ex. Arabic etc).
In Liferay 7 when we build theme then its "rtl" file auto generated. Liferay used gulp plugin to generate different files and configuration while building the theme. Sometimes we would not require these files and we want to override these configuration. So, our custom css files should load in rtl. We can achieve this by gulp hook after stopping the default build task for rtl file. Using below steps we can achieve this. By default there is below task defines in gulp file for theme build (in gulpfile.js under theme):

'use strict';

var gulp = require('gulp');
var liferayThemeTasks = require('liferay-theme-tasks');

liferayThemeTasks.registerTasks({
    gulp,
});

gulpfile.js run the task to build the theme which include multiple task in theme build. By default theme builder run build:r2 task to build these files.We can override this file with below content in which we remove this task. So, it will run all required theme build task except generation of rtl file:

 

'use strict';

var gulp = require('gulp');
var gulpif = require('gulp-if');
var log = require('fancy-log');
const debug = require('gulp-debug');
var gulpmatch = require('gulp-match');
var map = require('map-stream');
const plugins = require('gulp-load-plugins')();

var liferayThemeTasks = require('liferay-theme-tasks');
const lfrThemeConfig = require('liferay-theme-tasks/lib/liferay_theme_config');
const themeUtil = require('liferay-theme-tasks/lib/util');
const path = require('path');
const _ = require('lodash');
const {createBourbonFile} = require('liferay-theme-tasks/lib/bourbon_dependencies');


liferayThemeTasks.registerTasks({
    gulp: gulp,
    hookFn: function(gulp, options) {
        const {pathBuild, pathSrc} = options;
        const runSequence = require('run-sequence').use(gulp);
        gulp.task('build', function(cb) {
            runSequence(
                'build:clean',
                'build:base',
                'build:src',
                'build:web-inf',
                'build:liferay-look-and-feel',
                'build:hook',
                'build:themelets',
                'build:rename-css-dir',
                'build:compile-css',
                'build:fix-url-functions',
                'build:move-compiled-css',
                'build:remove-old-css-dir',
                'build:fix-at-directives',
                'build:war',
                cb
            );
        });

    }
});