-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
Describe the bug
process.env.NODE_ENV gets replaced and removes code in library mode. This is an undesirable behaviour as i want to have this check in the project i'm going to import the library.
Reproduction
export const testFunction = () => {
if (process.env.NODE_ENV === 'development') {
alert('This is a Test');
}
}
if build with vite build using this config:
import { defineConfig } from 'vite';
import * as path from 'path';
export default defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'myProject',
},
},
});
it will become:
const testFunction = () => {
};
System Info
Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
Memory: 8.36 GB / 15.94 GB
Binaries:
Node: 12.16.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 90.0.4430.93
Edge: Spartan (44.19041.906.0), Chromium (90.0.818.51)
Internet Explorer: 11.0.19041.1
npmPackages:
vite: ^2.2.3 => 2.2.3Used package manager: npm
Before submitting the issue, please make sure you do the following
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Provide a description in this issue that describes the bug.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
Reactions are currently unavailable