0

I am receiving sass code in string format. I would like to covert the sass string to css string and add it under tag in react component during runtime. Is there any possible way to do it? Or is there any webpack loader which allows to load sass code in style tag on react runtime?

... Sass code
  • This can help? https://stackoverflow.com/questions/39485126/compile-sass-file-inside-browser Use sass.js to compile it in the browser – Raz Ronen Aug 07 '20 at 19:31

1 Answers1

0

You can use this package Sass.js on your browser during runtime.

Selvin
  • 58
  • 1
  • 8
  • When i tried sass.renderSync in my react component to convert sass string to css string, i got below error in my browser. Uncaught Error: Cannot find module 'fs' at webpackMissingModule (sass.dart.js:112) at Object. (sass.dart.js:112) Does sass.js could be used only in nodejs ? not on plain js file or react component? – Catherine Aug 08 '20 at 13:22
  • Make sure you are not using node-sass. Please refer to this doc https://github.com/medialize/sass.js/blob/master/docs/getting-started.md – Selvin Aug 10 '20 at 12:07