Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get this to work with create-react app. #136

Open
dwjohnston opened this issue Jan 18, 2021 · 1 comment
Open

I can't get this to work with create-react app. #136

dwjohnston opened this issue Jan 18, 2021 · 1 comment

Comments

@dwjohnston
Copy link

dwjohnston commented Jan 18, 2021

Repro for this here.

https://github.com/dwjohnston/sassjs-cra

I'm trying to do the basic usage of this.

import logo from './logo.svg';
import './App.css';
//import Sass from "sass.js"; // memory dump
import Sass from "sass.js/dist/sass"; 
const sass = new Sass();  //SecurityError: Failed to construct 'Worker': Script at 'http://sass.worker.js/' cannot be accessed from origin 'http://localhost:3000'.

function App() {

  var scss = '$someVar: 123px; .some-selector { width: $someVar; }';
  sass.compile(scss, function(result) {
    console.log(result);
  });

  .... snip

And I get this error:

 //SecurityError: Failed to construct 'Worker': Script at 'http://sass.worker.js/' cannot be accessed from origin 'http://localhost:3000'.

Just looking at the instructions.

Ok, so maybe the basic usage doesn't work, and I'll need to do the 'set path to worker' thing.

import logo from './logo.svg';
import './App.css';
//import Sass from "sass.js"; // memory dump
import Sass from "sass.js/dist/sass"; 
Sass.setWorkerUrl('sass.js/dist/sass.worker.js')
const sass = new Sass();  

function App() {

  var scss = '$someVar: 123px; .some-selector { width: $someVar; }';
  sass.compile(scss, function(result) {
    console.log(result);
  });

  ...snip

This here doesn't crash, but it also doesn't log anything.

Is this issue basically the same as the other 'doesn't work with webpack' issues?

#64
#95

Has anyone got this working with CRA?

@dwjohnston
Copy link
Author

For anyone interested, I created this API to compile SASS via an HTTP endpoint:

https://github.com/dwjohnston/sass-compiler-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant