apps/full-site-editing/webpack.config.js
function getWebpackConfig( env = {}, argv = {} ) {
	env.WP = true;

	if ( 'theme' === argv.source ) {
		argv.entry = path.join( __dirname, 'blank-theme' );
		argv[ 'output-path' ] = path.join( __dirname, 'blank-theme', 'dist' );
		argv[ 'output-filename' ] = 'blank-theme.js';
	} else {
		argv.entry = path.join( __dirname, 'full-site-editing-plugin' );
		argv[ 'output-path' ] = path.join( __dirname, 'full-site-editing-plugin', 'dist' );
		argv[ 'output-filename' ] = 'full-site-editing-plugin.js';
	}

	const webpackConfig = getBaseWebpackConfig( env, argv );

	return {
		...webpackConfig,
		watch: isDevelopment,
		devtool: isDevelopment ? 'inline-cheap-source-map' : false,
	};
}
function getWebpackConfig( env = {}, argv = {} ) {
	env.WP = true;

	if ( 'theme' === argv.source ) {
		argv.entry = path.join( __dirname, 'blank-theme' );
		argv[ 'output-path' ] = path.join( __dirname, 'blank-theme', 'dist' );
		argv[ 'output-filename' ] = 'blank-theme.js';
	} else {
		argv.entry = path.join( __dirname, 'full-site-editing-plugin' );
		argv[ 'output-path' ] = path.join( __dirname, 'full-site-editing-plugin', 'dist' );
		argv[ 'output-filename' ] = 'full-site-editing-plugin.js';
	}

	const webpackConfig = getBaseWebpackConfig( env, argv );

	return {
		...webpackConfig,
		watch: isDevelopment,
		devtool: isDevelopment ? 'inline-cheap-source-map' : false,
	};
}
Return a webpack config object

Arguments to this function replicate webpack's so this config can be used on the command line,
with individual options overridden by command line args.

@see {@link https://webpack.js.org/configuration/configuration-types/#exporting-a-function}
@see {@link https://webpack.js.org/api/cli/}

@param  {object}  env                           environment options
@param  {object}  argv                          options map
@param  {object}  argv.source                   "plugin" or "theme"
@return {object}                                webpack config