trifid's avatar

Using custom different Boostrap _variables.scss depending on .env parameters in Laravel 8

Is there a way to use different bootstrap variables by using custom _variables file, selected upon some .env variable of Laravel 8?

something like, in app.scss:

if APP_VARIABLE = 1, then @import custom1_variables.scss

if APP_VARIABLE = 2, then @import custom2_variables.scss

and so on...

Would only want to select different _variables file, not the main app.scss file, which would be the same for all versions, but using its own _variables file.

What have I tried?

According to this solution of Stackoverflow, https://stackoverflow.com/questions/57111930/how-to-get-env-variable-in-scss I have done like this:

1 - Add my variables in .env file,

MIX_VARIABLES='variables1.scss'

2 - In my webpack.mix.js:

mix.sass('resources/sass/app.scss', 'public/css',
{prependData: 'custom_variables:\'resources/sass/'+process.env.MIX_VARIABLES+'\''}).version()

3 - Next, I have used my 'custom_variables' in my app.scss:

@import 'custom_variables';

But then I get an error of

Can't find stylesheet to import.

What am I missing?

0 likes
0 replies

Please or to participate in this conversation.