vite-plugin-env-compatible
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -30,3 +30,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create; | ||
var fs2 = require("fs"); | ||
var path2 = require("path"); | ||
var path3 = require("path"); | ||
function log(message) { | ||
@@ -66,3 +66,3 @@ console.log(`[dotenv][DEBUG] ${message}`); | ||
function config(options) { | ||
let dotenvPath = path2.resolve(process.cwd(), ".env"); | ||
let dotenvPath = path3.resolve(process.cwd(), ".env"); | ||
let encoding = "utf8"; | ||
@@ -152,3 +152,3 @@ let debug = false; | ||
function loadEnv(loadOptions) { | ||
const {mode, root, prefix, ignoreProcessEnv} = loadOptions; | ||
const {mode, envDir, prefix, ignoreProcessEnv} = loadOptions; | ||
if (mode === "local") { | ||
@@ -170,5 +170,5 @@ throw new Error(`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`); | ||
for (const file of envFiles) { | ||
const path2 = lookupFile(root, [file], true); | ||
if (path2) { | ||
const parsed = import_dotenv.default.parse(_fs2.default.readFileSync(path2), { | ||
const path3 = lookupFile(envDir, [file], true); | ||
if (path3) { | ||
const parsed = import_dotenv.default.parse(_fs2.default.readFileSync(path3), { | ||
debug: !!process.env.DEBUG || void 0 | ||
@@ -205,2 +205,3 @@ }); | ||
// src/index.ts | ||
function envCompatible(userOptions = {}) { | ||
@@ -216,9 +217,14 @@ const options = { | ||
const root = config.root || process.cwd(); | ||
let envDir = config.envDir || "./"; | ||
if (!_path2.default.isAbsolute(envDir || "")) { | ||
envDir = _path2.default.join(root, envDir); | ||
} | ||
const prefix = typeof options.prefix === "undefined" ? "VUE_APP_" : options.prefix; | ||
const env = loadEnv({ | ||
mode, | ||
root, | ||
prefix: options.prefix || "VUE_APP_", | ||
envDir, | ||
prefix, | ||
ignoreProcessEnv: _nullishCoalesce(options.ignoreProcessEnv, () => ( false)) | ||
}); | ||
const dynamicInjectedEnv = loadDynamicInjectedEnv(options.prefix || "VUE_APP_"); | ||
const dynamicInjectedEnv = loadDynamicInjectedEnv(prefix); | ||
const myDefine = {}; | ||
@@ -225,0 +231,0 @@ if (_optionalChain([options, 'access', _ => _.mountedPath, 'optionalAccess', _2 => _2.startsWith, 'call', _3 => _3("process.env")])) { |
{ | ||
"name": "vite-plugin-env-compatible", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Environment Variables Compatible", | ||
@@ -34,3 +34,3 @@ "main": "dist/index.js", | ||
"typescript": "4.1.3", | ||
"vite": "2.0.1", | ||
"vite": "2.5.1", | ||
"@commitlint/cli": "7.2.0", | ||
@@ -52,3 +52,3 @@ "@commitlint/config-conventional": "7.1.2", | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "avoid" | ||
"arrowParens": "always" | ||
}, | ||
@@ -55,0 +55,0 @@ "config": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13266
260