Search code examples
csslaravellaravel-8laravel-mix

How to compile multiple CSS files into two CSS files output based on each one required in different layout using Laravel Mix


I have two CSS files app.css(RTL CSS) and en-app.css(LTR CSS) I want to compile them using Laravel Mix into two files, How I can (I don't want to paste them directly in Public/CSS directory Instead I want to use advantages of Mix)


Solution

  • It should be quite straightforward. Usually you should have something like mix.js('resources/js/app.js', 'js').sass('resources/sass/app.scss', 'css'); in you mix file. As you can see you can stack multiple calls to the mix function. So you will need to make a separate call to .scss mix.js('resources/js/app.js', 'js').sass('resources/sass/app.scss', 'css').sass('resources/sass/en-app.scss', 'css');

    After running the compiler you should see the two files in the ./public/css/ folder.

    Note: If you are using plain CSS you will need to replace .scss with .css function in the mix file.