_setting.scss file to import not found or unreadable in Foundation 6 - sass

I've installed foundation 6 through foundation cli, and chose zurb-template. Everything is working ok when I run
foundation watch
From this moment, any file I change in src folder produces the reloading of the browser.
The problem arises when I change anything in my own _settings.scss.
The error message I get is:
Error in plugin 'sass'
Message:
src\assets\scss\app.scss
Error: File to import not found or unreadable: settings
Parent style sheet:
D:/wamp64/www/investoo_frontend2/src/assets/scss/app.scss
on line 3 of src/assets/scss/app.scss
>> #import 'settings';
^
My folder structure is:
my-project
├─ dist
├─ node-modules
├─ foundation-sites
├─ jquery
├─ what-input
├─ ...
├─ src
├─ assets
├─ js
├─ scss
├─ _settings.scss
├─ app.scss
In app.scss I am importing everything I need:
#charset 'utf-8';
#import 'settings';
#import 'foundation';
#import 'motion-ui';
#include foundation-global-styles;
#include foundation-grid;
In config.yml I am using the right pahts:
PATHS:
...
# Paths to Sass libraries, which can then be loaded with #import
sass:
- "src/assets/scss"
- "node_modules/foundation-sites/scss"
- "node_modules/motion-ui/src"
Any help?
Thanks a lot.

Have you tried to put #import 'settings' after #import 'foundation'?, actually as the last import on the list?

Related

#use shows undefined variable constantly

I am migrating from libsass to dartscss, so moving from #import to #use. I have around 20 sites and the way I have my sites is to have one scss folder with all of my scss files and then have a site config per site that uses variables to override the default colours.
My site structure
scss/
├─ import.scss
├─ base/
│ ├─ _reset.scss
site1/
├─ scss/
│ ├─ settigns/
│ │ ├─ _config.scss
│ import.scss
In site1/scss/settings/_config.scss I have the following code:
$bgc: red;
And in my site1/scss/import.scss I have:
#use "settings/config" as *;
#use "../../scss/import.scss";
And finally in ../../scss/import.scss I have a simple test call to see if it works.
body {
background-color: $bgc;
}
When I view my site I get undefined variable and $bgc doesn't render. I would like to keep the structure I had before since I have many sites that share the same scss folder and all worked fine before when I used #import.

How to override materializecss sass variables in vue?

I'd like to change variables in materialize _variables.scss e.g.
$primary-color: color("materialize-red", "lighten-2") !default;
$primary-color-light: lighten($primary-color, 15%) !default;
$primary-color-dark: darken($primary-color, 15%) !default;
/*...*/
In my Vue 2 main.js I include materialize style like this
require('materialize-css/sass/materialize.scss');
Because of !default I guess I need to include my _variables.scss before including materialize, but I don't know how.
So what's the proper way to set my own variables e.g. $primary-color: color("blue", "lighten-2") (I want to use predefined palette from materialize _colors.scss)?
EDIT 1: I installed vue2 with vue-cli
EDIT 2:
Folder structure:
├── build/
├── config/
├── dist/
├── node_modules/
│ ├── materialize-css
├── src/
│ ├── components
│ ├── router
│ └── main.js
├── package.json
└── index.html
Before changing any default settings in materialized css; first, you need to import the component for which you want to change the settings for. After this you can override the default settings and then you should import materialize. For example if you want to change default color then create a file for example app.scss then write following code:
//please put the paths as per yours project directory structure
#import "materialize-css/sass/components/color";
$primary-color: color("blue", "lighten-2") !default;
#import 'materialize-css/sass/materialize'
Note: app.css must be included in your page. As per my example app.css must be in your project root folder i.e. at same level as that of index.html
Now you can load app.scss or app.css in Vue 2 as
require('../app.scss');
Visit official materialized github repo for viewing complete source.
In matrialize 1.0.0 however,
follow these guildlines to override materialize colors:
Define the value for the variable that you want to override (eg. $primary-color)
Import the materialize.scss library
The definition of the override values must occur before importing the materialize.scss, that means that you can not use the matrial functions such as color()
Example:
// main.scss - the order of the imports is important !!!
#import './_colors';
#import 'materialize-css/sass/materialize.scss';
// _colors.scss
$primary-color: #03a9f4; //light-blue

Jekyll doesn't compile scss files with `jekyll serve`

I'm trying to create a website using Jekyll, and everything worked fine. Until I wanted to custom the design.
I've updated my css/main.scss in order to include my custom theme in _sass/theme.scss:
// Import partials from `sass_dir` (defaults to `_sass`)
#import
"base",
"layout",
"syntax-highlighting",
"theme"
;
I've also updated _config.yml, because jekyll serve -H 0.0.0.0 didn't compile my new sass file. I've added the following:
sass:
sass_dir: _sass
The problem is jekyll serve doesn't compile my sass files, I always see the default css. I've also tried to copy the content of _sass/theme.scss directly at the end of css/main.scss, but nothing happened.
Until I modified one of those files while jekyll serve was running. The thing is jekyll-watch understands my updates and compile the scss files. May I have done something wrong for jekyll build don't compile sass files at the first try?
In case you need it, here my project tree:
.
├── _config.yml
├── css
│   ├── main.css
│   └── main.scss
├── _images
├── img
├── index.html
└── _sass
├── _base.scss
├── _layout.scss
├── _syntax-highlighting.scss
└── _theme.scss
Does someone know how to fix this?
Thank you,
Ok, I get it !
You have a css/main.css files that is copied as a static file in _site/css/main.css.
The problem is that it has the same name as the css/main.scss target which is also _site/css/main.css.
So at first build :
css/main.scss is processed to main.css
then, when static files are copied, it is overridden by css/main.css.
Solution : delete css/main.css
Have you added the front matter to the top of your main.scss file?
First add to your config.yml
sass:
sass_dir: _sass
Then add to top in your main.scss file, two dashed lines https://jekyllrb.com/docs/assets/
---
---
#charset "utf-8";
After that write in your cmd console
jekyll serve
and check your compilation.
I've run into similar issues when trying to use Jekyll to pass YAML content into partials. It looks like this workflow is not possible.
The work around was to place all variables on the main SCSS file and get Jekyll to populate the values from YAML, then using partials for the actual styles.
Here's a simple repo with some of my solutions: https://github.com/guschiavon/jekyllfy-sass

compass config issues on compilation / watch

I have this:
Project
├───public_html/
│ ├───css/
│ | └───style.css
│ |
│ ├───img/
│ |
│ ├───js/
│ |
│ └───index.html
|
├───scss/
│ ├───ie.scss
│ ├───print.scss
| └───style.scss
|
└───config.rb
config.rb
http_path = "/"
css_dir = "public_html/css"
sass_dir = "scss"
output_style = :compressed
and I'm doing:
compass watch "scss/style.css"
Its creating (overriding) the style.css as expected. (so far so good).
But when I edit the style.scss and save it its compiling inside the scss folder with this:
...
├───scss/
| ├───.sass-cache/
| ├───ie.css
| ├───ie.scss
| ├───print.css
| ├───print.scss
│ ├───screen.css
│ ├───screen.scss
│ └───config.rb
...
like ignoring the first config.rb and moving the root inside the scss folder.
In addition I just want screen.scss compiled, the rest will be included.
Any ideas? Thanks
As a solution I've ended up compiling the files directly from the scss forlder and I now have there the main config.rb
I still would like to have control about where the config.rb is and the subfolders that are getting filled in the compilation process.
If anyone has a way to better control this, please let me know.
The other thing: "to compile just a few of the scss files"
The way to do this is to rename the files you don't want to be compiled starting with underscore
_print.scss (instead of print.scss). The good thing is that you can still import the files as you normally would, without the underscore (even if the actual file has the starting underscore)
#import "print.scss"

How to import scss file in compass only if it exists?

I need to have special scss file that is different for every installation of the project, so I don't want to include it in git archive. But everything should work even if this file doesn't exist.
Is there any way to #import scss file only if it exists, ignoring file not found error?
You'll need to make use of the "import-path" option to do this, where the path you're importing contains the fallback files you want to import (in our case, we want an empty file).
Option 1: Vanilla Sass
File structure
├── fallback
├── _example.scss // <-- our blank file
├── _example.scss // <-- the file for the user to customize (optional)
├── style.scss
In style.scss:
#import "example";
/* the rest of our styles */
When you run your sass command, you would write it like this:
sass --watch ./css:./sass --load-path ./sass/fallback
Note that the fallback directory does not have to be inside your sass directory, it be anywhere on the filesystem you like.
See also: How does SCSS locate partials?
Option 2: Compass Extension
You may find that creating a Compass extension is a little more convenient if you're using this technique in multiple projects. It will automatically setup the load-path for you. You can learn more about creating extensions here: http://compass-style.org/help/tutorials/extensions/
Maybe with sass-globbing and a naming convention for optional files follow a specific order of loading.
Consider the following tree:
stackoverflow-14975341/
├── .gitignore
├── config.rb
├── css/
│   └── screen.css
└── sass/
├── optionals/
│   ├── .gitkeep
│   ├── _01_style.scss
│   └── _03_style.scss
└── screen.scss
with these files:
# config.rb
require 'sass-globbing'
sass_dir = 'sass'
css_dir = 'css'
relative_assets = true
and
// sass/screen.scss
#import "optionals/*";
and
// sass/optionals/_01_style.scss
.optional1 {
background-color: red;
}
and
// sass/optionals/_03_style.scss
.optional3 {
background-color: green;
}
and, for in the .gitignore:
sass/optional/*
Finally, to keep the optional folder, create an empty file named .gitkeep (the file name is not important).
When you compile the stylesheet, Compass generates the screen.css even if the file _02_style.scss is missing.
// css/screen.css
/* line 1, ../sass/optionals/_01_style.scss */
.optional1 {
background-color: red;
}
/* line 1, ../sass/optionals/_03_style.scss */
.optional3 {
background-color: green;
}
It is certainly possible to improve the system based on import additional paths.

Resources