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

vite-plugin-env-color

v0.0.5

Published

Create a color file with your environment variables in Vite Js

Downloads

7

Readme

When? 🧐

Register color with ENV and use it when you want to make it into a Javascript or Css or Scss file.

Installation 💻

Install the package as a development dependency:

npm i -D vite-plugin-env-color
# pnpm add -D vite-plugin-env-color
# yarn add -D vite-plugin-env-color

Usage 🚀

You can provide a list of environment variable names to expose to your client code:

import { defineConfig } from 'vite'
import VitePluginEnvColor from 'vite-plugin-env-color'

export default defineConfig({
  plugins: [
    VitePluginEnvColor(),
  ],
})

Usage with default values 📌

VitePluginEnvColor({
  // DEFAULT ENV FILTER NAME
  ENV_FILTER_NAME: 'VITE_COLOR',
  
  // DEFAULT ENV FILTER THEME NAME
  ENV_THEME_FILTER_NAME: 'VITE_THEME', 

  // DEFAULT ENV FILTER THEMES 
  ENV_THEME_COLOR_FILTER_NAMES: ['VITE_THEME_DARK', 'VITE_THEME_LIGHT'],

  // DEFAULT SCRIPT FILE NAME
  TS_FILE_NAME: 'color',  

  // DEFAULT SCRIPT PATH
  TS_BASE_PATH: './src',

  // DEFAULT CSS FILE NAME
  CSS_FILE_NAME: 'color',  

  // DEFAULT CSS PATH
  CSS_BASE_PATH: './public/css',

  // DEFAULT SCSS FILE NAME
  SCSS_FILE_NAME: 'color',

  // DEFAULT SCSS PATH
  SCSS_BASE_PATH: './src/assets',

  // BUILD JS
  IS_BUILD_JS: true,

  // BUILD SCSS
  IS_BUILD_SCSS: true,

  // BUILD CSS
  IS_BUILD_CSS: true,
}),

Default Output Example ⚖️

ENV

VITE_COLOR_BLACK=000
VITE_COLOR_RED=F44336
VITE_COLOR_BLUE=0B5394
VITE_COLOR_GRAY=EEE
VITE_COLOR_WHITE_SMOKE=F5F5F5

VITE_THEME_DARK_RED=000
VITE_THEME_DARK_BLUE=EEE
VITE_THEME_DARK_SKY_BLUE=111

VITE_THEME_LIGHT_RED=333
VITE_THEME_LIGHT_BLUE=777
VITE_THEME_LIGHT_SKY_BLUE=EEE

Created Ts File

// color
export type ColorType = 'black' |'red' |'blue' |'gray' |'whiteSmoke' ;
export type Color = Record<ColorType, string>;

// dark theme color
export type DarkColorType = 'red' |'blue' |'skyBlue' ;
export type DarkColor = Record<DarkColorType, string>;

// light theme color
export type LightColorType = 'red' |'blue' |'skyBlue' ;
export type LightColor = Record<LightColorType, string>;

export const color: Color = {
  black: '#000',
  red: '#F44336',
  blue: '#0B5394',
  gray: '#EEE',
  whiteSmoke: '#F5F5F5',
}
export const darkColor: DarkColor = {
  red: '#000',
  blue: '#EEE',
  skyBlue: '#111',
}
export const lightColor: LightColor = {
  red: '#333',
  blue: '#777',
  skyBlue: '#EEE',
}

Created Css File

html {
  /* color */
  --black: #000;
  --red: #F44336;
  --blue: #0B5394;
  --gray: #EEE;
  --whiteSmoke: #F5F5F5;

  /* rgb */
  --black-RGB: 0, 0, 0;
  --red-RGB: 244, 67, 54;
  --blue-RGB: 11, 83, 148;
  --gray-RGB: 238, 238, 238;
  --whiteSmoke-RGB: 245, 245, 245;
}

/* dark theme */
html[data-theme=dark] {
  /* color */
  --red: #000;
  --blue: #EEE;
  --skyBlue: #111;

  /* rgb */
  --red-RGB: 0, 0, 0;
  --blue-RGB: 238, 238, 238;
  --skyBlue-RGB: 17, 17, 17;
}

/* light theme */
html[data-theme=light] {
  /* color */
  --red: #333;
  --blue: #777;
  --skyBlue: #EEE;

  /* rgb */
  --red-RGB: 51, 51, 51;
  --blue-RGB: 119, 119, 119;
  --skyBlue-RGB: 238, 238, 238;
}

Created Scss File

html {
  // color
  --black: #000;
  --red: #F44336;
  --blue: #0B5394;
  --gray: #EEE;
  --whiteSmoke: #F5F5F5;

  // rgb
  --black-RGB: 0, 0, 0;
  --red-RGB: 244, 67, 54;
  --blue-RGB: 11, 83, 148;
  --gray-RGB: 238, 238, 238;
  --whiteSmoke-RGB: 245, 245, 245;
}

// dark theme
html[data-theme=dark] {
  // color
  --red: #000;
  --blue: #EEE;
  --skyBlue: #111;

  // rgb
  --red-RGB: 0, 0, 0;
  --blue-RGB: 238, 238, 238;
  --skyBlue-RGB: 17, 17, 17;
}

// light theme
html[data-theme=light] {
  // color
  --red: #333;
  --blue: #777;
  --skyBlue: #EEE;

  // rgb
  --red-RGB: 51, 51, 51;
  --blue-RGB: 119, 119, 119;
  --skyBlue-RGB: 238, 238, 238;
}

License 📝

This library is available as open source under the terms of the MIT License.