How is sls.lib.webpack.isLocal defined while build?

Trying to setup webpack serverless plugin for building lambda functions. When reading about and viewing various webpack.config.js, the mode setting is defined as:

{
...
    mode: slsw.lib.webpack.isLocal ? "development" : "production"
...
}

So how is this variable defined. Also if I am building the lambda functions by the serverless package command then how is the isLocal affected or assigned by the stage setting in the serverless.yml file under provider:stage option?

Basically I wanted to create a webpack.config.js which builds those lambda functions and want to slightly change optimization and code minification settings based on the stage of the build process.