UNPKG

1.31 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.setupEnvVariables = exports.ENV_VARIABLES_ENV_NAME = void 0;
4const get_environment_1 = require("./get-environment");
5exports.ENV_VARIABLES_ENV_NAME = 'ENV_VARIABLES';
6const getEnvVariables = () => {
7 if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
8 const param = window.remotion_envVariables;
9 if (!param) {
10 return {};
11 }
12 return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
13 }
14 if ((0, get_environment_1.getRemotionEnvironment)() === 'preview') {
15 // Webpack will convert this to an object at compile time.
16 // Don't convert this syntax to a computed property.
17 return {
18 ...process.env.ENV_VARIABLES,
19 NODE_ENV: process.env.NODE_ENV,
20 };
21 }
22 throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
23};
24const setupEnvVariables = () => {
25 const env = getEnvVariables();
26 if (!window.process) {
27 window.process = {};
28 }
29 if (!window.process.env) {
30 window.process.env = {};
31 }
32 Object.keys(env).forEach((key) => {
33 window.process.env[key] = env[key];
34 });
35};
36exports.setupEnvVariables = setupEnvVariables;