diff --git a/cli/plasmo/src/features/env/env-config.ts b/cli/plasmo/src/features/env/env-config.ts index 7b1296c95..760e1200e 100644 --- a/cli/plasmo/src/features/env/env-config.ts +++ b/cli/plasmo/src/features/env/env-config.ts @@ -89,6 +89,12 @@ function maybeParseJSON(value: string): any { return match ? JSON.parse(match[1]) : value } +export const setInternalEnv = (env: Record) => { + for (const [key, value] of Object.entries(env)) { + process.env[`${INTERNAL_ENV_PREFIX}${constantCase(key)}`] = value + } +} + export const getEnvFileNames = () => { const nodeEnv = process.env.NODE_ENV const flagMap = getFlagMap() diff --git a/cli/plasmo/src/features/helpers/create-parcel-bundler.ts b/cli/plasmo/src/features/helpers/create-parcel-bundler.ts index f7c03ee7b..786d84b55 100644 --- a/cli/plasmo/src/features/helpers/create-parcel-bundler.ts +++ b/cli/plasmo/src/features/helpers/create-parcel-bundler.ts @@ -11,6 +11,7 @@ import { Parcel, type ParcelOptions } from "@plasmohq/parcel-core" import type { PlasmoManifest } from "~features/manifest-factory/base" import { getPackageManager } from "./package-manager" +import { setInternalEnv } from "~features/env/env-config" const PackageInstallerMap = { npm: ParcelPM.Npm, @@ -104,6 +105,8 @@ export const createParcelBuilder = async ( : ["last 1 Chrome version"] } + setInternalEnv(bundleConfig) + const bundler = new Parcel({ inputFS, packageManager,