Specifically I am not super clear why it's looking...
# ask-questions
w
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
Usually, the
process.env.
code is removed by whatever code bundler you are using - webpack, rollup, etc.
w
Really strange. I am actually using Rollup in this instance for what it's worth.
f
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
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
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
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