sass.js
sass.js copied to clipboard
Error: Can't resolve 'fs'
Hello there!
First of all thank you very much for ~droids~ library I've spend a lot of time to looking for. Now it's freaking easy to compile my sass scripts while code is running in browser. It seems to work fine at all (there I mean that code works and compiles like expected) except one little thing. An error appers while using webpack.
The error:
ERROR in ./node_modules/sass.js/dist/sass.sync.js
Module not found: Error: Can't resolve 'fs' in 'C:\Projects\nr-fontface\node_modules\sass.js\dist'
@ ./node_modules/sass.js/dist/sass.sync.js 62:1108-1121 62:382030-382043
@ ./src/index.js
I'm confused but that error really doesn't prevent my code from working and compiling.
Further I've found the solution to add this to my webpack.config.js
:
node: {
fs: "empty"
}
Is it really a total solution or you can recommend smth. more elegant?
The way I'm using your lib for now:
import sass from "sass.js";
sass.compile(sassString, result => {});
fs
comes from emscripten. I have not used sass.js in a webpack environment, only loaded it in the browser as static asset - I have no idea why webpack is complaining here, to be honest.
Is it really a total solution or you can recommend smth. more elegant?
I'd have probably done the same thing.
@rodneyrehm You should add -s ENVIRONMENT="web"
to build line for sass.sync.js
and -s ENVIRONMENT="worker"
for sass.worker.js
. See https://gist.github.com/surma/b2705b6cca29357ebea1c9e6e15684cc#gistcomment-2771604. Can you tag a new version?
@hason building sass.js with -s ENVIRONMENT="web"
seems to break use in node - at leas the tests fail completely:
Running "mochaTest:src" (mochaTest) task
>> Mocha exploded!
>> ReferenceError: document is not defined