Codesandbox-client: Being able to run sandboxes in production mode

Created on 6 Jun 2019  路  7Comments  路  Source: codesandbox/codesandbox-client

馃寛 Feature

Quoting Dan Abramov on Twitter:

at least, for React, just switching NODE_ENV is enough. Maybe offer an option?

I wasn't aware that csb isn't running in prod, had no idea that dev mode in general has this kind of impact: https://twitter.com/dan_abramov/status/1136526025393754112

The original demo is here: https://codesandbox.io/s/peaceful-johnson-txtws it goes so slow that it's barely moving at all.

I am mostly using csb for presentational matters, when you want to demonstrate a library in the best light or some functionality. It would be nice to know the underlying framework's doing its best. 馃檪

馃帓 Bundler 馃 Improvement

Most helpful comment

Good point! The tricky thing about enabling "production mode" is that we don't do the uglifying/tree-shaking, so we need to communicate clearly that we're only changing the environment variable there and that it doesn't reflect real prod apps.

There are two ways I can think of making this work:

  1. We add it as an option to sandbox.config.json
  2. We fix the sandbox if NODE_ENV=production in .env file. We do support .env files right now, but I added a hardcoded optimization to only include the dev bundle in the case of React. That's why this doesn't work: https://codesandbox.io/s/jovial-jepsen-efe8f. I can remove the optimization in case of a changed env variable, it would also be good to document this better.

All 7 comments

Good point! The tricky thing about enabling "production mode" is that we don't do the uglifying/tree-shaking, so we need to communicate clearly that we're only changing the environment variable there and that it doesn't reflect real prod apps.

There are two ways I can think of making this work:

  1. We add it as an option to sandbox.config.json
  2. We fix the sandbox if NODE_ENV=production in .env file. We do support .env files right now, but I added a hardcoded optimization to only include the dev bundle in the case of React. That's why this doesn't work: https://codesandbox.io/s/jovial-jepsen-efe8f. I can remove the optimization in case of a changed env variable, it would also be good to document this better.

Both seem like a good way, thanks for considering this Ives!

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

still much needed :-)

True, removing the label

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

This issue has been automatically closed because there wasn't any activity after the previous notice or the stale label wasn't removed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miukimiu picture miukimiu  路  3Comments

Haroenv picture Haroenv  路  3Comments

NataliaTepluhina picture NataliaTepluhina  路  3Comments

kentcdodds picture kentcdodds  路  3Comments

zocky picture zocky  路  3Comments