npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pixeloven-core/env

v6.4.0

Published

Environment loader

Downloads

4

Readme

@pixeloven-core/env

Pixel Oven env.

See our website PixelOven for more information or our issues board to report issues associated with this package.

Install

Using npm:

npm install --save @pixeloven-core/env

or using yarn:

yarn add @pixeloven-core/env

Usage

Note this package should only be used for node based applications. Using in a client setting may have unintended consequences.

This package acts as a simple wrapper for dotenv and a light weight interface for accessing our .env file variables. The philosophy for this project enforces only a single environment file aptly named .env. It is our opinion that having multiple .env definitions is an anti-pattern and should be discouraged.

The ideal setup for this particular configuration is to have a single .env file that's not committed to source control and instead should be manged the deployment process (or local development environment). Of course the deployment process may simply be pre-defined .env-{template} files in source that get deployed based on environment but these details we leave to you. :heart:

Alright, enough lecturing let's get to coding! ;)

To use this package is simple. For example let use the following .env file as an example.

PORT=8080
HOST=localhost
PROTOCOL=http
PUBLIC_URL=/
BUILD_PATH=dist
LOG_LEVEL=debug
MACHINE=host
DOMAIN=pixeloven.com

The above ENV variables are some examples of common configurations used in our projects some of which are even defined in this package. Of course more variables can be added by simply following the below pattern.

VARIABLE_NAME=value

Now, in some cases it is required to defined environment variables at run time. For example if we wanted to bootstrap our build script to create a production build of our application.

import { env, Environment } from "@pixeloven/env";

/**
 * Initialize env variables from file
 */
env.load();

/**
 * Setup production environment
 */
const environment: Environment = "production";
env.define("BABEL_ENV", environment);
env.define("NODE_ENV", environment);

Once again this packages pre-defines a few common variables and even provides type definitions but we are not limited to just what is defined by this package.

Enjoy!