Paul_Fry's avatar

Frontend / Backend seperation compile separate less

Hi Guys,

I'm struggling with a problem.

I'm in the process of moving an existing e-Commerce sure to a new Laravel 5 app.

They have entirely different front-end / backend templates, each with a bunch of .less files.

Could someone help me work out how to compile each .less file and store in a separate directory. ie.

'resources/assets/less/frontend.less' -> / public/css/style.css 'resources/assets/less/backend.less' -> / public/css/admin/style.css

I'm new to laravel and exilr.....

I've tried to separate mix's and it runs but does not do anything

Thanks in advance

0 likes
3 replies
Paul_Fry's avatar
            elixir(function(mix) {
                    mix.less(  'less/frontend.less ' , 'css/style.css' , 'resources/assets/less/frontend.less' )
                    .less( 'less/backend.less' , 'css/admin/style.css' , 'resources/assets/less/backend.less'  );
            });

This is my lame attempt, no errors produced but no css compiled either

JeffreyWay's avatar
Level 59

The third argument to mix.less() is the base directory that you want to use. You don't need it in this case, since you're using the default. Try:

elixir(function(mix) {
    mix.less('less/frontend.less', './public/css/style.css')
       .less('less/backend.less', './public/css/admin/style.css');
}); 

Does that do the trick for you?

3 likes
Paul_Fry's avatar

I moved all less files to 'resources/less', then Jeffrey's code worked.

Much appreciated.

            elixir(function(mix) {
                    mix.less( 'styles.less', './public/css/styles.css')
                     .less( 'admin/less/theme/theme_styles.less', './public/css/admin/theme_styles.css' );
            }); 

Please or to participate in this conversation.