E
E
Eugene2020-11-10 10:53:09
Laravel
Eugene, 2020-11-10 10:53:09

How to specify folder for images from sass in Laravel mix?

Tell me this moment.
So that images and fonts, when compiling SASS, fall into the folder I need, I specify the directives

mix.config.fileLoaderDirs.images = '/myFolder1/images';
mix.config.fileLoaderDirs.fonts ='/myFolder1/fonts';

But the fact is that I have several SASS packages compiled for the client and admin parts. How to share it?
Those. so that this directive is applied only to the task I need.

I tried to reassign, by specifying directly before the task, but it does not work
mix.config.fileLoaderDirs.images = '/myFolder1/images';
mix.config.fileLoaderDirs.fonts ='/myFolder1/fonts';
mix.sass('resources/app1.scss', '/myFolder1/app.css');

// Переназначаю папки хранения images и fonts
mix.config.fileLoaderDirs.images = '/myFolder2/images';
mix.config.fileLoaderDirs.fonts ='/myFolder2/fonts';
mix.sass('resources/app2.scss', '/myFolder2/app.css');

But no. The directive is indicated to be seen only once and, accordingly, is simply overwritten by the last value.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2020-11-10
@atachrus

Why, in fact, push two projects into one config? Write different ones, and run them separately.
I don't remember now if it is possible to specify different .mix.js files in package.json. But you can definitely write conditional constructions inside this file. It's just a js file. So be guided by the environment variables that you set in the command line ..

F
feycot, 2020-11-10
@feycot

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .copyDirectory('resources/assets/img', 'public/img');

This is how mix works in this project https ://github.com/fey/hexlet-sicp/blob/master/web...
if you need to copy different files from different directories, you can try this method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question