deno icon indicating copy to clipboard operation
deno copied to clipboard

Sass Support

Open vikaskaliramna0 opened this issue 3 years ago • 9 comments

Sass Lang

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

vikaskaliramna0 avatar Oct 30 '22 02:10 vikaskaliramna0

but Deno panicked

What is the panic?

crowlKats avatar Oct 30 '22 02:10 crowlKats

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);

vikaskaliramna0 avatar Oct 30 '22 03:10 vikaskaliramna0

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).

jrson83 avatar Nov 01 '22 03:11 jrson83

I used the deno-sass wrapper created by binyamin.

And I am still facing Uri.base error.

vikaskaliramna0 avatar Nov 02 '22 02:11 vikaskaliramna0

I used the deno-sass wrapper created by binyamin.

And I am still facing Uri.base error.

Did you use the synchronous API?

jrson83 avatar Nov 02 '22 14:11 jrson83

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

oscarotero avatar Nov 25 '22 13:11 oscarotero

I also have this problem now. Does Deno have a plan to repair it?

jiawei397 avatar Feb 07 '23 02:02 jiawei397

@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.

oscarotero avatar Feb 07 '23 16:02 oscarotero

@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.

Thank you very much. This has helped me a lot.

jiawei397 avatar Feb 08 '23 10:02 jiawei397