Skip to content

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

@dwjohnston

Description

@dwjohnston

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions