I'm new in Sass ( SCSS ). In Sass I follow 7-1 pattern
and currently I am using Phpstorm as IDE.
I import all my _<name>.scss
files in one main file called main.scss
file.
Problem
I define my color variables in _variables.scss
file but when I use it in other .scss file, PhpStorm gives error like
Element 'gutter-horizontal' (variable name) is resolved only by name without use of explicit imports more...
I also give screenshot of my IDE so, you know structure of my folder.
I check all over internet but I can't find any solution, this is not duplicate question of this question ok !!
When I import my _variables.scss
in my scss files, error gone.
So, do I need to import vaiables.scss
in my all scss files or I done something wrong ?
I don't understand this problem coming from where ? Sass or PhpStorm ?
variables.scss
// COLORS
$color-primary: #55c57a;
$color-primary-light: #7ed56f;
$color-primary-dark: #28b485;
$color-gray-dark: #777;
$color-black: #000;
$color-white: #fff;
// GRID
$grid-width: 114rem;
$gutter-vertical: 8rem;
$gutter-horizontal: 6rem;
main.scss
@charset "UTF-8";
@import 'abstracts/variables';
@import 'abstracts/functions';
@import 'abstracts/mixins';
@import 'base/animations';
@import 'base/base';
@import 'base/typography';
@import 'base/utilities';
@import 'components/buttons';
@import 'layout/header';
@import 'layout/grid';
@import 'pages/home';
No, you're doing it correctly. Have one main.scss file and make sure your variables are the first thing that you import (otherwise you will run into undefined variable issues in other files). You do not need to re-import your variables for each file as long as they are all included in your main.scss file.
I normally ignore this PhpStorm error, or you can turn it off:
File
-> Settings
Editor
-> Inspections
in the left panelSass/SCSS
in the right panelMissing import
(or Resolved by name only
on older versions)In GoLand version 2021 the item Resolved by name only
was renamed:
Preferences
-> Editor
-> Inspections
-> Sass/SCSS
(in the right panel)Missing Import
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With