Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sass, check if file exists

Tags:

sass

Is it possible to check if a file exists with sass (.scss) I want to import a file if it exists and if not import another file. Is that possible?

I'm not using compass (suggested duplicate question)

like image 818
WIRN Avatar asked Dec 02 '16 09:12

WIRN


People also ask

What is the use of the @import function in Sass?

The SASS @import function helps us to import multiple SASS or CSS stylesheets together such that they can be used together. Importing a SASS file using the @import rule allows access to mixins, variables, and functions to the other file in which the other file is imported.

What is@ use in SCSS?

The @use rule loads mixins, functions, and variables from other Sass stylesheets, and combines CSS from multiple stylesheets together. Stylesheets loaded by @use are called "modules". Sass also provides built-in modules full of useful functions.

How do I import an HTML file into SCSS?

You can not "import" a SASS/SCSS file to an HTML document. SASS/SCSS is a CSS preprocessor that runs on the server and compiles to CSS code that your browser understands.


1 Answers

Unfortunately there is no way to do this. If you import a file which doesn't exist, you will get an error immediately (even if it is placed under a false condition)

it is discussed here

also functionality of import described here comprehensively

like image 65
Reza Mohammadi Avatar answered Oct 15 '22 08:10

Reza Mohammadi