how to use sass variables from a CDN - css

I've a project that uses create-react-app and a remotely hosted colors.scss file that only has the definition of colors inside (content below).
$color-blue: #2281ff;
$color-cyan: #11a0f2;
$color-lue-light: #cfd7fc;
Next I've an index.scss that looks the following way:
#import url('http://url.domain/colors.scss');
body: {
background-color: $color-blue;
}
When the app is being build I get the following error
SassError: Undefined variable: "$color-blue".
on line 4 of src/index.scss
>> background-color: $color-blue;
this is when using node-sass
Next I've tried changing node-sass to dart-sass which is just sass so ran npm uninstall node-sass and then npm install sass
my file looked like this
#use url('http://url.domain/colors.scss');
body: {
background-color: $color-blue;
}
this yielded an error
SassError: Expected string.
╷
1 │ #use url('http://url.domain/color.scss');
rewriting the import to
#use "http://url.domain/color.scss";
yielded
SassError: Can't find stylesheet to import.
╷
1 │ #use "http://url.domain/color.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
is it not possible to use variables from a remote source? Or am I missing something?
NOTE: http://url.domain/color.scss is an abstracted version of the link, when the real one is pasted into the browser I can see the correct stylesheet with variables loaded.

Yes, you cannot use the variables defined in the remote SCSS file. We ran into a similar issue. So, we downloaded the remote scss file as part of the build process and referenced the downloaded file as a local file.

Related

Integrating Metronic with Laravel 8 - Webmix Failing

I am in the process of integrating Metronic 8 with Laravel 8.
I have followed the guide from Metronic in their documentation but when I run npm run dev it webmix gets to 98% and then fails with the following output:
ERROR in ./resources/src/sass/style.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
6 │ #import "../../../../tools/node_modules/bootstrap/scss/root";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
resources/src/sass/components/components.scss 6:9 #import
resources/src/sass/style.scss 12:9 root stylesheet
at processResult (/Users/jakefeeley/Sites/certhub/saas/node_modules/webpack/lib/NormalModule.js:721:19)
at /Users/jakefeeley/Sites/certhub/saas/node_modules/webpack/lib/NormalModule.js:827:5
at /Users/jakefeeley/Sites/certhub/saas/node_modules/loader-runner/lib/LoaderRunner.js:399:11
at /Users/jakefeeley/Sites/certhub/saas/node_modules/loader-runner/lib/LoaderRunner.js:251:18
at context.callback (/Users/jakefeeley/Sites/certhub/saas/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
at /Users/jakefeeley/Sites/certhub/saas/node_modules/sass-loader/dist/index.js:54:7
at Function.call$2 (/Users/jakefeeley/Sites/certhub/saas/node_modules/sass/sass.dart.js:95825:16)
at _render_closure1.call$2 (/Users/jakefeeley/Sites/certhub/saas/node_modules/sass/sass.dart.js:83882:12)
at _RootZone.runBinary$3$3 (/Users/jakefeeley/Sites/certhub/saas/node_modules/sass/sass.dart.js:28060:18)
at _FutureListener.handleError$1 (/Users/jakefeeley/Sites/certhub/saas/node_modules/sass/sass.dart.js:26590:21)
ERROR in /assets/js/scripts.bundle
Module not found: Error: Can't resolve '/Users/jakefeeley/Sites/certhub/saas/resources/src/webpack/scripts.js' in '/Users/jakefeeley/Sites/certhub/s
My webpack.mix.js file looks exactly like the example on the documentation:
https://preview.keenthemes.com/metronic8/demo1/documentation/getting-started/integration/laravel.html
I figured it out.
In the docs where Metronic tells you to swap ../../../../tools for ~, i just had to ignore that and just leave it at the root. e.g 'node_modules/bootstrap/scss/root'

Nuxt using incorrect loader for scss

I am attempting to set up a nuxt project with scss. I added the following packages to my project:
"sass": "^1.37.0",
"sass-loader": "10",
and I updated nuxt.config.js to say the following to point to my new scss main file:
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'~/assets/sass/main.scss'
],
I had to use older versions because i was getting errors with certain functions I was using but i managed to get it working correctly on my local machine, and it builds just fine repeatedly as I update code as well.
I am now trying to deploy to staging on a Linux/nginx server and I am getting the following errors when building npm run build:
ERROR in ./assets/sass/main.scss (./node_modules/css-loader/dist/cjs.js??ref--7-oneOf-1-1!./node_modules/postcss-loader/dist/cjs.js??ref--7-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--7-oneOf-1-3!./assets/sass/main.scss)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
SyntaxError
(1:1) postcss-custom-properties: <css input> Unknown word
> 1 | var(--font-size-2)/var(--font-ratio)
| ^
It looks like it's using css builder instead of sass builder! Does anyone know how to fix this? I doublechecked that the files on the server include the sass-loader and that the config is pointing to my .scss file, and i checked the documentation which states that Nuxt will automatically choose the correct loader.
What am I doing wrong?

Materialize Module Build Failed: Invalid CSS / Expected Selector

I'm using Sage framework to build a WordPress site and would like to use a custom CSS framework, which is Materialize CSS. Sage uses Webpack to build the CSS.
Upon building, I get the following error message:
WAIT Compiling... 1:55:57 PM
ERROR Failed to compile with 1 errors 1:55:57 PM
error in ./resources/assets/styles/main.scss
Module build failed:
.#{$color_name}.#{$color_type} {
^
Invalid CSS after ".white": expected selector, was ".#0a0a0a"
in /mnt/c/Users/Kenny/Local Sites/ngcsaget1/app/public/wp-content/themes/ngc11/node_modules/materialize-css/sass/components/_color-classes.scss (line 14, column 7)
# ./resources/assets/styles/main.scss 2:14-358 21:1-42:3 22:19-363
# multi ./resources/assets/build/util/../helpers/hmr-client.js ./scripts/main.js ./styles/main.scss
Here's the Materialize Github repo: https://github.com/Dogfalo/materialize
If needed, here's the github for the Sage framework, the webpack.config.js is in the build folder: https://github.com/roots/sage/tree/master/resources/assets
note:
I get the error when I try to import the .scss file:
#import "~materialize-css/sass/materialize";
If I import the full .css file, I get access to the framework, but it's plain ol' css:
#import "~materialize-css/dist/css/materialize";
Here's the webpack code: https://github.com/roots/sage/blob/master/resources/assets/build/webpack.config.js

Sass::SyntaxError on Rails Production Precompile

I tried to precompile my project on production but it gives me this error and I don't know as to where it is pointing to since it's really vague.
Sass::SyntaxError: Invalid CSS after "": expected selector, was "#media print"
(in /home/deploy/production/project-name/app/assets/stylesheets/admin.css)
(sass):124
The path links to the manifest file of the admin/ folders of my assets.
Some of the stylesheets' format is .css.scss.erb.
Check your sass files in your app/assets/ directory.
I think you're using sprockets in your admin.css at line 124?
You'll see the file you want to include having an sass syntax error.
Example:
# app/assets/admin.css
/* ..
(line 124) * require my-file
.. */
now you should look for the my-file.

Meteor fourseven:scss throws "file to import not found or unreadable"

I am using the meteoric package and I keep getting this error.
client/style.scss: Scss compiler error: undefined
/Users/lucanaterop/Desktop/lend/client/style.scss:3: file to import not
found or unreadable:
'.meteor/local/build/programs/server/assets/packages/meteoric_ionicons-sass/ionicons.css.sass'
The error is known to disappear when the meteor server is restarted, but that doesn't happen.
It only happens if I try to include the ionicons-sass:
#import '.meteor/local/build/programs/server/assets/packages/meteoric_ionicons-sass/ionicons.css.sass';
It does not appear on the ionic-sass import:
#import '.meteor/local/build/programs/server/assets/packages/meteoric_ionic-sass/ionic';
There's currently an issue with the package right now... It's documented here: https://github.com/meteoric/ionicons-sass/issues/7
Temporary solution until this get fixed (I got this off the same github page):
Replace...
#import '.meteor/local/build/programs/server/assets/packages/meteoric_ionicons-sass/ionicons';
with...
#import 'http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css';
(you can also choose to download the css and import it locally, but to do that you'll need to download the font files too and put it in ../public/fonts/...)

Resources