importing multiple scss files not working in express app - sass

I am using node-sass-middleware and so far i had one scss file and it was working just fine. Now created another scss file and using the second file link on top the first file using this.
#media screen and (min-width: 769px) {
.quizes-container {
justify-content: space-between;
.card {
width: 32.5%;
}
}
.quiz-container-title {
div {
padding-right: 1em;
}
}
}
and imported like this #use 'media_queries';
However in my .css output the codes from the second file is not showing at all.
I am really confused.

SCSS files need to be imported using the #import keyword.
#import "media_queries";

node-sass-middleware uses node-sass for compiling sass to css, However node-sass is deprecated.
Warning: LibSass and Node Sass are deprecated. While they will
continue to receive maintenance releases indefinitely, there are no
plans to add additional features or compatibility with any new CSS or
Sass features. Projects that still use it should move onto Dart Sass.
and even node-sass-middleware is dead (I think) because there is no activity and no new releases.
Github Open Question
If you want to continue with this then you need to use old #import syntax, the new syntax #use will not work.
#import "media_queries";
Or switch to new Dart Sass
Implementing node-sass-middleware with new dart sass, use this gist, create new file (sass-middleware) and add the content to newly created file, then import it like this, then you are good to go.
/*index.js*/
//const sassMiddleware = require('node-sass-middleware');
const sassMiddleware = require('./sass-middleware');
Note: That gist I have created is a copy of node-sass-middleware but with new dart sass implementation, So all credit goes to node-sass-middleware

Related

Platform-specific-css in Nativescript Angular

I'm trying to apply platform-specific-css in my Nativescript Angular Mobile App.
For example, for the home component, currently I have home.component.tns.css to style it. But I also need to handle some styles separately for IOS and Android.
Here's what I have tried:
Add a css file named as home.component.ios.tns.css. Not working, the css in this file won't be applied.
Add a css file named as home.component.ios.css. This time the css is applied. But I lost the css in home.component.tns.css
I import home.component.tns.css in home.component.ios.css like this: #import './home.component.tns.css'; This time I got an error saying NativeScript encountered a fatal error: Error: Could not resolve home.component.tns.css
I guess I wasn't using the platform specific css in the right way. Anyone can help?
Unless you are doing a shared-project (web + NS in 1 project).
To set up platform specific styling in NativeScript you need to name your files like this:
home.component.ios.css
home.component.android.css
In your home.component.ts you'll set up your styles binding like this:
styleUrls: ['./home.component.css']
NativeScript will take the respective platform .css file and generate the contents of the base home.component.css file with the platform specific style sheet .ios.css or .android.css.
You can't import home.component.tns.css because there will only by home.component.css available.
You can put all your css in home.component.ios.css.
Or you can use the .android and .ios classes like :
.ios .myClass {
background-color: red;
}
.android .myClass {
background-color: blue;
}
The platform specific files should be like:
yourcustom.component.css
styles.component.ios.css
styles.component.android.css

Problem overriding some Bulma Sass variables

I am trying to customize Bulma by overriding some Sass variables.
In my app.scss file I import the files using the following order:
#import 'node_modules/bulma/sass/utilities/initial-variables';
#import 'node_modules/bulma/sass/utilities/functions';
#import 'bulma_overrides';
#import 'node_modules/bulma/bulma';
The file bulma_overrides.scss includes the following:
$footer-padding: 3rem 1.5rem 3rem;
$footer-background-color: whitesmoke;
My goal was to make the footer a little bit thinner, and I tried to achieve this by changing the padding from 3rem 1.5rem 6rem to 3rem 1.5rem 3rem. At the same time I am changing the backgroud color to whitesmoke.
After running and successfully building:
npm run watch
I reload the page.
Result:
The background color of the footer changes just fine but the padding does not.
At first, I thought that maybe this is not something we can customize, but the official documentation says that we can:
https://bulma.io/documentation/layout/footer/
Any ideas why? By the way, I faced the same issue with another variable in a previous project, and I can't understand what is going on.
PS1: i am using Laravel 5.7 for this project. No changes are done in webpack.mix.js
PS2: i tried multiple browsers (Chrome, Firefox, Safari, Edge[lol]) but no luck.
Your bulma import is already importing "sass/utilities/_all", so this app.scss worked for me just fine:
// Bulma Overrides
#import 'bulma_overrides';
// Bulma
#import '~bulma/bulma';

Bulma Navbar Color Modifiers are Not Working

Adding color modifier classes to Bulma's navbar is supposed to change the background color (as mentioned here: http://bulma.io/documentation/components/navbar/#colors).
I find that this is working fine if I use the css version. But I"m using the sass version and it is not working.
Any idea why not?
Note -- this is also an unanswered issue on Github: https://github.com/jgthms/bulma/issues/1192
You have to create file like my-bulma-theme.scss, then override needed variables or import other .scss files with variables and finally, import bulma from node_modules and include that my-bulma-theme.scss in your pages/preprocessor.
For example my-bulma-theme.scss:
$navbar-background-color: #f0f0f0;
$another-bulma-variable: 14px;
#import './another-style-variables.scss';
#import '../node_modules/bulma/bulma.sass'; // must be the last thing in file
I updated to version 0.5.2 of Bulma and now it works as it should.

Change Bulma default colours with scss without downloading/installing

I am attempting to simply change the colour of the "is-primary" class in bulma. I am attempting to write a scss file to change the values without installing bulma via npm. I am attempting to import by using the cloudfare link, is this possible?
this is my scss file:
#import "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4./css/bulma.cssbulma/sass/utilities/initial-variables";
$tech-blue : #2c3e50;
$primary : $tech-blue;
#import "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.3/css/bulma.css";
This file compiles but I cannot find the corresponding css file and makes no affect to my actual page.
I don't think that this is possible. The variables in use by Bulma are only accessible by SCSS. So you need to build the whole thing to have your colors blend in. The rendered CSS already contains:
a {
color: #00d1b2; /* can't change that later on */
…
}
A feature request for Bulma would be to make those variables accessible via CSS variables. That way you could easily customize the look even with the pre-rendered CSS from the CDN.

How to configure Koala Sass auto compile on partials changes?

I'm using Koala for Win64 to compile sass (with lot of partials) to css with no problems, but Koala auto compile function is only runs when there are updates in root scss file, so I need to open Koala and press 'compile' button every time when I made changes to included partials.
Is there any way to configure scss auto compile to watch for changes in sass partials?
So came across this as I was having problems myself. Just documenting...
1st thing I did
was to create a style.scss or global.scss (making sure to setup "Auto Compile" in Koala) and only fill it with imports:
#import 'layout'; //_layout.scss
#import 'layout_modules'; // _layout_modules.scss
#import 'modules'; // _modules.scss
#import 'theme'; // _theme.scss
When I would work on the partials (partials will have a _ in front of the filename) and save I would get an autocompile confirmation (Koala Settings > General > "Notification when compile is completed")
But _layout_modules.scss would not trigger autocompile on save. If I switched over to another partial and saved, it would autocompile and Koala would still throw helpful errors for _layout_modules.scss.
2nd thing I did
then, was to remove the extra underscore in the filename - so it would just be _layoutmodules.scss (make sure to update your #import on style.scss) and worked as expected.
(I've been using Sass for all of 5 days.)
Short answer:
add _ before partial files and import them to the main file.
Thanks to #philtune

Resources