SassError: argument `$color` of `darken($color, $amount)` must be a color
SassError: argument `$color` of `darken($color, $amount)` must be a color
我正在尝试使用以下 SCSS 代码在 Bulma 中添加自定义颜色图:
// Set your colors
$primary: #5B43CC;
$primary-invert: findColorInvert($primary);
$twitter: #4099FF;
$twitter-invert: findColorInvert($twitter);
$facebook: #4267B2;
$facebook-invert: findColorInvert($facebook);
$custom-colors: (
"foo": (black, grey),
);
// Import Bulma's core
@import "~bulma/sass/utilities/_all";
// Links
$link: $primary;
$link-invert: $primary-invert;
$link-focus-border: $primary;
// Import Bulma and Buefy styles
// this has been moved to App.vue because it must be at the end
@import "~bulma";
@import "~buefy/src/scss/buefy";
但是我得到以下错误:
ERROR Failed to compile with 6 errors 1:26:26 AM
error in ./src/App.vue?vue&type=style&index=0&lang=scss&
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: argument `$color` of `darken($color, $amount)` must be a color
on line 150 of node_modules/bulma/sass/elements/button.sass, in function `darken`
from line 150 of node_modules/bulma/sass/elements/button.sass
from line 4 of node_modules/bulma/sass/elements/_all.sass
from line 5 of node_modules/bulma/bulma.sass
from line 40 of src/assets/scss/main.scss
from line 2 of /c/Users/Raj/Projects/testsite/src/App.vue
>> background-color: darken($color-invert, 5%); }
----------------------------^
@ ./node_modules/vue-style-loader??ref--8-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=0&lang=scss& 4:14-416 14:3-18:5 15:22-424
@ ./src/App.vue?vue&type=style&index=0&lang=scss&
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
但是,如果我注释掉 // $primary-invert: findColorInvert($primary);
,那么错误就会消失。此外,如果 // set your colors
下的代码段移到 @import "~bulma/sass/utilities/_all"
之后,则错误也会消失。
我做错了什么?
注意,这是 this previous post
的后续
因此,正如我在评论中提到的,当涉及到 Sass 编译时,一切都与排序有关(import
s and/or 变量声明)。现在,由于这些颜色反转在此处使用名为 findColorInvert
, which resides within utilities/functions.sass
, we can't probably import the utilities
with the original order 的 Bulma 实用程序。
我们可以拆分它们并在 functions
和 derived-variables
之间插入我们的习俗:
@import "~bulma/sass/utilities/initial-variables";
@import "~bulma/sass/utilities/functions";
// Set your colors
$primary: #5B43CC;
$primary-invert: findColorInvert($primary);
$twitter: #4099FF;
$twitter-invert: findColorInvert($twitter);
$facebook: #4267B2;
$facebook-invert: findColorInvert($facebook);
// Links
$link: $primary;
$link-invert: $primary-invert;
$link-focus-border: $primary;
$custom-colors: (
"foo": (black, grey),
);
@import "~bulma/sass/utilities/derived-variables";
@import "~bulma/sass/utilities/animations";
@import "~bulma/sass/utilities/mixins";
@import "~bulma/sass/utilities/controls";
我正在尝试使用以下 SCSS 代码在 Bulma 中添加自定义颜色图:
// Set your colors
$primary: #5B43CC;
$primary-invert: findColorInvert($primary);
$twitter: #4099FF;
$twitter-invert: findColorInvert($twitter);
$facebook: #4267B2;
$facebook-invert: findColorInvert($facebook);
$custom-colors: (
"foo": (black, grey),
);
// Import Bulma's core
@import "~bulma/sass/utilities/_all";
// Links
$link: $primary;
$link-invert: $primary-invert;
$link-focus-border: $primary;
// Import Bulma and Buefy styles
// this has been moved to App.vue because it must be at the end
@import "~bulma";
@import "~buefy/src/scss/buefy";
但是我得到以下错误:
ERROR Failed to compile with 6 errors 1:26:26 AM
error in ./src/App.vue?vue&type=style&index=0&lang=scss&
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: argument `$color` of `darken($color, $amount)` must be a color
on line 150 of node_modules/bulma/sass/elements/button.sass, in function `darken`
from line 150 of node_modules/bulma/sass/elements/button.sass
from line 4 of node_modules/bulma/sass/elements/_all.sass
from line 5 of node_modules/bulma/bulma.sass
from line 40 of src/assets/scss/main.scss
from line 2 of /c/Users/Raj/Projects/testsite/src/App.vue
>> background-color: darken($color-invert, 5%); }
----------------------------^
@ ./node_modules/vue-style-loader??ref--8-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=0&lang=scss& 4:14-416 14:3-18:5 15:22-424
@ ./src/App.vue?vue&type=style&index=0&lang=scss&
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
但是,如果我注释掉 // $primary-invert: findColorInvert($primary);
,那么错误就会消失。此外,如果 // set your colors
下的代码段移到 @import "~bulma/sass/utilities/_all"
之后,则错误也会消失。
我做错了什么?
注意,这是 this previous post
的后续因此,正如我在评论中提到的,当涉及到 Sass 编译时,一切都与排序有关(import
s and/or 变量声明)。现在,由于这些颜色反转在此处使用名为 findColorInvert
, which resides within utilities/functions.sass
, we can't probably import the utilities
with the original order 的 Bulma 实用程序。
我们可以拆分它们并在 functions
和 derived-variables
之间插入我们的习俗:
@import "~bulma/sass/utilities/initial-variables";
@import "~bulma/sass/utilities/functions";
// Set your colors
$primary: #5B43CC;
$primary-invert: findColorInvert($primary);
$twitter: #4099FF;
$twitter-invert: findColorInvert($twitter);
$facebook: #4267B2;
$facebook-invert: findColorInvert($facebook);
// Links
$link: $primary;
$link-invert: $primary-invert;
$link-focus-border: $primary;
$custom-colors: (
"foo": (black, grey),
);
@import "~bulma/sass/utilities/derived-variables";
@import "~bulma/sass/utilities/animations";
@import "~bulma/sass/utilities/mixins";
@import "~bulma/sass/utilities/controls";