How do you turn on Production mode for Redux Toolkit in the browser?

Viewed 764

I really am loving the Redux Toolkit, but it has some warnings that I know I can safely ignore (non-serializable values in an action being sent to some thunks; in this case an API) but I want to make sure they do not show up in the shipped application.

I can't seem to find how to turn on production mode which would skip the "serializable-state-invariant-middleware" when I deploy a finished version to the browser. I know I could modify the list of middleware to avoid it, but that seems really clunky.

1 Answers

I'm the creator and maintainer of Redux Toolkit.

Like most libraries in the NPM ecosystem, production mode is detected based on process.env.NODE_ENV being set to 'production'. This happens automatically in most build tools, such as Webpack's mode: 'production'

Create-React-App and other meta-build frameworks also ensure this is set automatically, so you shouldn't have to worry about it.

You can review the contents of a production bundle using source-map-explorer to help confirm that it's behaving as expected.

(Also, note that the "non-serializable values in actions" message with createAsyncThunk is a bug that we will be fixing shortly.)

Related