0

could you please tell me how to access env variable in scss.Here is my code

https://repl.it/@naveennsit/DirtyAcrobaticClasslibrary

I am able to access env variable in jsx like that

<a>About sss{process.env.customKey}</a>

I created env variable like this

module.exports = {
  env: {
    customKey: "my-value",
    red: "red",
    bg:'data:image/jpeg;base64,

Now I want to access variable in scss file.But I am getting error.

I am trying to access like this

// background-image: url($process.env.bg})

any update ?

user5711656
  • 3,310
  • 4
  • 33
  • 70
  • but `nextjs` framework has provisions to add additional data .Not sure how to acheive this – user5711656 Nov 11 '20 at 03:11
  • in `sass-loader` i will pass `additional data` but I am not aware how to pass this things – user5711656 Nov 11 '20 at 03:12
  • Maybe [this answer](https://stackoverflow.com/q/60058352/367865) will help. – Ouroborus Nov 11 '20 at 03:15
  • @Ouroborus ye this is correct .I am looking that only .But issue is `nextjs` already used `sass-loader` in build I need there should be another way to send variable in `sass` – user5711656 Nov 11 '20 at 03:20
  • You can't access your `env` variable inside sass, you need to "allow" it. Check this answer of mine, https://stackoverflow.com/questions/63912418/access-environment-variables-from-sass-in-next-js/63914630#63914630 – felixmosh Nov 11 '20 at 07:36

0 Answers0