Tuesday, 14 June 2022

scss, css import styling file.scss css file starts with _

 https://stackoverflow.com/questions/34889962/why-put-in-front-of-the-file-name-or-in-scss-css

Suppose your folder structure is like this

/scss
 style.scss
 _list.scss
/css

if you run the command

sass --watch scss:css

only style.css and style.css.map files will be created, sass compiler will omit _list.scss without converting its content into a CSS file.

/scss
 style.scss
 _list.scss
/css
 style.css
 style.css.map

the only way that you can use partials is to import them into another .scss file with

@import 'list.scss';

if you remove the '_' in front of _list.scss the outcome of the command will be

/scss
 style.scss
 list.scss
/css
 style.css
 style.css.map
 list.css
 list.css.map

The main purpose of using partials is to break down our CSS code into several pieces which are easier to maintain. Hope this helps. Thanks.


in .json file

still need _list.scss for fullPath

No comments:

Post a Comment