PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How to change envPrefix in vite react?

 August 22, 2022     environment-variables, prefix, reactjs, vite     No comments   

Issue

I created a simple react app using npm init vite Appname -- --template react command.
And in .env file, variables have to have VITE_ prefix, and don't look good.
I checked this guide, but don't know how to change the envPrefix. Can someone tell me how to change envDir and envPrefix?

Thank you in advance for many help.

This is my vite.config.js file.

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()]
})

Solution

Try updating the file to include the properties that you shared the docs for:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  envPrefix: 'CH_',
  envDir: './environment'
})


Answered By - Alexander Staroselsky
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing