Laravel-mix: Cannot Mix 2 CSS files with different PostCSS setup

Created on 31 Mar 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

Hi,
Using RTLCss a great tool for multi-lang sites.. it turns your LTR styles into RTL styles, so you write your styles 1 time only and magic happens 馃寛

my RTL css files are simply a copy of my LTR one with slight modifications like fonts etc..
with the example below, both files turned into RTL styles 馃槩

i need a way to separate the PostCss plugins, i cant find anything on the subject..

  • Laravel Mix Version: 0.9.2
  • Node Version: 7.7.4
  • NPM Version: 7.7.4
  • OS: Win10

Description:

Cannot Mix 2 CSS files with different PostCSS setup..

Steps To Reproduce:

mix.sass('resources/assets/sass/app_en.scss', 'public/css');

mix.sass('resources/assets/sass/app_ar.scss', 'public/css').options({
    postCss: [require('rtlcss')()]
});

doing this manually during every time you change styles is a real pain 馃槺

Thanks

Most helpful comment

@JeffreyWay understandable, but a way to separate setups would be great

did a little workaround .. here it is for the 2 people out there who may need this..
i used the mix then() event and triggered the RTLCss with nodejs exec()

const exec = require('child_process').exec

mix.sass('resources/assets/sass/app_en.scss', 'public/css')
    .sass('resources/assets/sass/app_ar.scss', 'public/css');

mix.then(() => {
    exec('rtlcss ./public/css/app_ar.css ./public/css/app_ar.css', (error, stdout, stderr) => {
        if (error) {
            console.error(`exec error: ${error}`);
            return;
        }
        console.log(`stdout(RTLCSS): ${stdout}`);
        console.log(`stderr(RTLCSS): ${stderr}`);
    });
});

馃榾

All 3 comments

Yeah Mix doesn't work that way. Sorry, probably not possible to do what you need right now.

@JeffreyWay understandable, but a way to separate setups would be great

did a little workaround .. here it is for the 2 people out there who may need this..
i used the mix then() event and triggered the RTLCss with nodejs exec()

const exec = require('child_process').exec

mix.sass('resources/assets/sass/app_en.scss', 'public/css')
    .sass('resources/assets/sass/app_ar.scss', 'public/css');

mix.then(() => {
    exec('rtlcss ./public/css/app_ar.css ./public/css/app_ar.css', (error, stdout, stderr) => {
        if (error) {
            console.error(`exec error: ${error}`);
            return;
        }
        console.log(`stdout(RTLCSS): ${stdout}`);
        console.log(`stderr(RTLCSS): ${stderr}`);
    });
});

馃榾

Better than running the rtlcss manually each time you change the styles. Works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

terion-name picture terion-name  路  3Comments

pixieaka picture pixieaka  路  3Comments

Cheddam picture Cheddam  路  3Comments

rderimay picture rderimay  路  3Comments