deno
deno copied to clipboard
Sass Support
Currently there is a Uri.base error which occurs due to window.location. I tried to fix it and that error was fixed with 4-5 lines of code but Deno panicked.
Support Sass CLI and Sass JavaScript API would be great. Importing StyleSheet within frameworks like Fresh or Aleph. It would also allow processing sass content with PostCSS after sass support
but Deno panicked
What is the panic?
Sorry for delay. I am not sure the code I wrote was correct or not but the previous error was not showing so I guess it was doing the right job.
The Panic I got
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: windows x86_64
Version: 1.27.0
Args: ["deno", "run", "-A", "--unstable", "compile.ts"]
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\a\deno\deno\serde_v8\de.rs:573:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The Code I wrote
import SassLang from 'npm:sass@latest';
window.location = {
href : Deno.cwd()
};
const Content = await SassLang.compile('Package/Common.scss');
console.log(Content);
The denosass module is not maintained well and lacks many features, but binyamin created deno-sass, a wrapper for dart-sass, which works flawless (also with @use & @forward).
I used the deno-sass wrapper created by binyamin.
And I am still facing Uri.base error.
I used the deno-sass wrapper created by binyamin.
And I am still facing Uri.base error.
Did you use the synchronous API?
I'm trying to use the official NPM Sass package and have the same issue:
// main.js
import sass from "npm:sass";
const code = sass.compile("styles.scss", {
includePaths: [import.meta.resolve("./_includes")]
});
console.log(code);
// styles.scss
@import "vars.sass";
body {
font: 100% $font-stack;
color: $primary-color;
}
// _includes/vars.sass
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
It seems that sass depends on a value in window.location, so I need to run with --location:
deno run -A --location="https://deno.land" main.js
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos x86_64
Version: 1.28.2
Args: ["deno", "run", "-A", "--location=https://deno.land", "main.js"]
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/work/deno/deno/serde_v8/de.rs:573:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I also have this problem now. Does Deno have a plan to repair it?
@jiawei397 The problem is SASS detects Deno as if it was in a browser environment instead of Node, because only check if the window object exists (and Deno has window).
You can use @lumeland/sass, that contains the same code as the official sass package but including a fix in this detection, so it works on Deno.
@jiawei397 The problem is SASS detects Deno as if it was in a browser environment instead of Node, because only check if the
windowobject exists (and Deno haswindow).You can use @lumeland/sass, that contains the same code as the official sass package but including a fix in this detection, so it works on Deno.
Thank you very much. This has helped me a lot.