I may be missing something very obvious here, but what is the purpose of the underscores in LESS files? I can understand why they are used in JS files (considering the Gruntfile config) but I have no clue in regards to LESS files. I looked around the repository, commit messages and did a forum and Google search but couldn’t find anything on that matter. The only reason I can think about is making obvious the difference between default and custom Bootstrap files.
It’s just to note that the files are ‘partials’ and are imported from main.less
. It’s not actually relevant to Less (although some Less compilers follow this rule…), but it is with Sass:
You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain. A partial is simply a Sass file named with a leading underscore. You might name it something like
_partial.scss
. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the@import
directive.
Feel free to remove the underscore prefix if you don’t like it. Looks like Bootstrap might be adding underscore prefixes in v4: Prefix partial LESS source files with underscore · Issue #12902 · twbs/bootstrap · GitHub
Now I get it! Looks like I was searching for this answer in the wrong place, then. I didn’t know this naming convention until now.
Thanks, @ben!