https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
w

worried-yacht-64692

04/18/2023, 2:37 PM
Specifically I am not super clear why it's looking for the process variable like it was running in a Node environment. I don't see documentation at the moment about what I need to do in order to get it to work in "browser mode"
f

future-teacher-7046

04/18/2023, 4:18 PM
Usually, the
process.env.
code is removed by whatever code bundler you are using - webpack, rollup, etc.
w

worried-yacht-64692

04/18/2023, 4:25 PM
Really strange. I am actually using Rollup in this instance for what it's worth.
f

future-teacher-7046

04/18/2023, 4:27 PM
Ok, you might need to add a plugin to Rollup. Should look something like this:
Copy code
plugins: [
    replace({
      "process.env.NODE_ENV": JSON.stringify("production"),
      preventAssignment: true,
    }),
  ]
Frameworks like Next.js automatically add this to the bundler, but it looks like Lit is more barebones and doesn't include anything by default
w

worried-yacht-64692

04/18/2023, 4:28 PM
Let me take a stab at that one 😉 thank you so much for the pointer though, I had no chance of figuring that out on my own
Jeremy! Thank you again so much for that one I really appreciate it. It now looks to be working!
f

future-teacher-7046

04/18/2023, 5:27 PM
We can add a note to the docs about this. I'm sure you aren't the only one who's using Lit or another framework without a built in bundler.
w

worried-yacht-64692

04/20/2023, 10:32 AM
Honestly it may be a good idea! Just from an onboarding perspective it's the kind of thing that can kill momentum pretty quickly without enough motivation. If it's any help at all the simple demo I put together has 2 examples of this. The first is here where I am using Rollup for a production build using the code you mentioned to me. https://github.com/mark-looptimize/growthbook-demo/blob/main/rollup.config.js#L31 and the second is in a local development environment where I am using something that is quite popular in the Lit community at least called
@web/dev-server
that is implemented like so https://github.com/mark-looptimize/growthbook-demo/blob/main/web-dev-server.config.mjs#L24 and finally a 60 line example implementation using a Lit pattern for code composition they call ReactiveControllers https://github.com/mark-looptimize/growthbook-demo/blob/main/src/feature-controller.ts
10 Views