I am using gulp-sass to compile SCSS, but received the following error message:
[19:51:38] 'sassTask' errored after 98 ms
[19:51:38] Error in plugin 'gulp-sass'
Message:
assets\scss\base\_typography.scss
Error: Undefined variable: "$color-grey-dark".
on line 6 of assets/scss/base/_typography.scss
from line 7 of assets/scss/main.scss
>> color: $color-grey-dark;
Here are my variables from scss/abstracts/_variables.scss
$color-primary: #55c57a;
$color-primary-light: #7ed56f;
$color-primary-dark: #28b485;
$color-grey-dark: #777;
$color-white: #fff;
$color-black: #000;
Here's where I used the $color-grey-dark in scss/base/_typography.scss which generated the error message:
body {
font-family: "Lato", sans-serif;
font-weight: 400;
/* font-size: 16px; */
line-height: 1.7;
color: $color-grey-dark;
padding: 3rem;
box-sizing: border-box;
}
and here is my code from assets/scss/main.scss:
#import "abstracts/variables";
#import "abstracts/functions";
#import "abstracts/mixins";
#import "base/animations";
#import "base/base";
#import "base/typography";
#import "base/utilities";
#import "components/button";
#import "layout/header";
#import "pages/home";
I did put variables at the top of the list, since I read that the wrong order of your imports can create problems, but that didn't fix it.
How can I fix this error? Here is a link to the repo of the project in case that's helpful: https://github.com/chris-fretz/natours-project.
Seems to be a problem with your pathes ... ;-)
In your project on github you #import file _variables.scss from directory "abstracts/variables".
The file in that directory is empty!!!
The file _variables.scss with the variables you want to load is placed in assets directly. So you may try #import 'variables ... or just move the file with the variables to the right place.
Additional nice notice: in that situation it could be helpful to check the pathes for other files as well i.e. mixins, functions, ... ;-)
Related
I want to compile my scss that that an #import rule remains present at the head of the css file. I've tried using #at-root to write a string or #{"#import url(...)"} but these end up trying to be imported and compiled. I've been up and down the documentation https://sass-lang.com/documentation/syntax but can't figure out how to output a raw string to the root.
input
#import url(http://some-file.com/foo.css);
.myclass {
p { font-weight: bold; }
}
how do you output a raw strig to the document root of the compiled output?
desired output
#import url(http://some-file.com/foo.css);
.myclass p { font-weight: bold}
I installed zurb-foundation using npm and tries to import the .scss of the former to my App.scss file. I'm using the "live sass server" for the compilation of the .scss code to .css code. While the .css file gets created but it shows no code even though I imported the .scss from foundation to my App.scss
pic shows the .scss code on the left and corresponding .css code on the right
if you have three file:
SASS SYNTAX
first file:
SASS SYNTAX
// foundation/_code.sass
code
padding: .25em
line-height: 0
second file:
// foundation/_lists.sass
ul, ol
text-align: left
& &
padding:
bottom: 0
left: 0
you can add your files with import like this.
note: the name of file have to have this syntax:
_{name of file}.sass
// app.sass
#import foundation/code, foundation/lists
SCSS SYNTAX
first file:
// foundation/_code.scss
code {
padding: .25em;
line-height: 0;
}
second file:
// foundation/_lists.scss
ul, ol {
text-align: left;
& & {
padding: {
bottom: 0;
left: 0;
}
}
}
third file:
// style.scss
#import 'foundation/code', 'foundation/lists';
for more info study: sass docs #import
have you also tried #import '../node_modules/foundation-sites/scss/foundation.scss'?
But maybe you could just pick what you really need to use, for instance the breakpoint mixins for your scss, like:
#import "~foundation-sites/scss/util/util";
#import "~foundation-sites/scss/util/breakpoint";
otherwise the whole foundation code will be compiled to your css file, maybe you don't need everything.
You can also have a look at https://get.foundation/sites/docs/sass.html
I am importing a Sass file into my component with
#import 'src/assets/sass/var'
In the browser everything is correct but WebStorm tells me:
Error: Can't find stylesheet to import.
#import 'src/assets/sass/var'
home.component.css looks like this:
/* Error: Can't find stylesheet to import.
* ,
* 1 | #import 'src/assets/sass/var'
* | ^^^^^^^^^^^^^^^^^^^^^
* '
* home.component.sass 1:9 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Can't find stylesheet to import.\a \2577 \a 1 \2502 #import 'src/assets/sass/var'\d\a \2502 ^^^^^^^^^^^^^^^^^^^^^\a \2575 \a home.component.sass 1:9 root stylesheet";
}
Why do I get this error?
The error comes from SASS compiler, not from the IDE. You need to specify a valid relative path in import, or pass a load path to the compiler to get the import resolved.
Just change the import to #import "./path/from/your/file/var";, or use --load-path option (see https://sass-lang.com/documentation/cli/dart-sass#load-path) in your compiler arguments to specify a folder the compiler should look for .scss file in. Note that the folder path should be relative to compiler working directory (specified in file watcher Working directory: field)
While I was creating theme with Bourbon, I got the error below:
error sass/screen.scss (Line 18 of sass/bourbon/css3/_background.scss: \
$string: linear-gradient(10deg, #217142,#214271) is not a string for `str-slice')
Here's code in _background.scss, as it's on its Github repo:
#mixin background($backgrounds...) {
$webkit-backgrounds: ();
$spec-backgrounds: ();
#each $background in $backgrounds {
$webkit-background: ();
$spec-background: ();
$background-type: type-of($background);
#if $background-type == string or list {
$background-str: if($background-type == list, nth($background, 1), $background);
# line 18 just below:
$url-str: str-slice($background-str, 0, 3);
$gradient-type: str-slice($background-str, 0, 6);
#if $url-str == "url" {
$webkit-background: $background;
$spec-background: $background;
}
}
}
}
I was using Sass 3.3.14 & Compass 1.0.0.rc.1 to create the theme in order to get full benefits of bourbon.
UPDATE:
(Oops, I've forgotten telling about Neat or Bitters. I am using them, too. Sorry.)
I've updated files as being described on Bitters' guide on Github:
#import 'compass';
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
But same error occurs.
I've got similar error
error (Line 18 of bourbon/css3/_background.scss: $string: linear-gradient(#c73b3c,#b8201f) is not a string for `str-slice')
when added the #import 'compass'; in a working bourbon/neat/bitters environment. removing it fixed the problem. importing after thoughtbot's libraries gives bunch of warnings instead of errors but working.
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
#import 'compass';
The problem seems to be related to the $base-line-height variable.
In compass $base-line-height set to $base-line-height 24px;
In bourbon $base-line-height set to $base-line-height: 1.5;
when compass loaded after bourbon you get a WARNING: $base-line-height must resolve to a pixel unit.
because bourbon set it to 1.5.
If you try to add $base-line-height: 24px; before the #import 'compass'; command you get error:
(Line 36 of /usr/local/lib/ruby/gems/2.1.0/gems/compass-core-1.0.1/stylesheets/compass/typography/_vertical_rhythm.scss: Incompatible units: 'em' and 'px'.)
because $base-font-size is also conflicting between the libraries.
A solution I found is to set the imports like this:
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
$base-font-size: 16px;
$base-line-height: 24px;
#import 'compass';
Now you have both playing together. I couldn't make it to work other way around where compass is imported before bourbon. I guess this conflict should be fixed at libraries level (bourbon?).
I've got a file called app.scss, inside that file I'm making four #imports:
#import "settings";
#import "foundation";
#import "type";
#import "custom";
I'm defining a $main-color variable like this in settings.scss:
$main-color: blue;
But for some reason when I reference that file in custom.scss, I get an error:
body {
background-color: $main-color;
}
Any idea what might be causing this problem? Thanks in advance!
You should rename settings.scss/custom.scss to _settings.scss/_custom.scss.