function getBuildSystemDefine ({
  fileEnv = {},
  buildEnv = {},
  buildRawDefine = {}
}) {
  const acc = {}

  for (const key in fileEnv) {
    const val = fileEnv[ key ]
    acc[ `process.env.${ key }` ] = val === 'true' || val === 'false'
      ? val // let's keep it as boolean and not transform it to string
      : JSON.stringify(fileEnv[ key ])
  }

  const flatBuildEnv = flattenObject(buildEnv)
  for (const key in flatBuildEnv) {
    acc[ `process.env.${ key }` ] = JSON.stringify(flatBuildEnv[ key ])
  }

  for (const key in buildRawDefine) {
    const val = buildRawDefine[ key ]
    acc[ key ] = typeof val === 'string'
      ? buildRawDefine[ key ]
      : JSON.stringify(buildRawDefine[ key ])
  }

  return acc
}
Get the final env definitions to supply to
the build system (Vite or Esbuild).