-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React, Uncaught ReferenceError: process is not defined #9186
Labels
invalid
This doesn't seem right
Comments
Hello @osama996. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
0sama
changed the title
React, Uncaught ReferenceError: process is not defined index.js
React, Uncaught ReferenceError: process is not defined
Jul 18, 2022
I'm having this same issue on('file:preprocessor', async (file) => {
const { filePath, outputPath } = file;
const filename = path.basename(outputPath);
const filenameWithoutExtension = path.basename(outputPath, path.extname(outputPath));
const viteConfig = {
jsx: 'react',
plugins: [flowPlugin(), react()],
build: {
emptyOutDir: false,
minify: false,
outDir: path.dirname(outputPath),
sourcemap: true,
write: true,
},
};
if (filename.endsWith('.html')) {
viteConfig.build.rollupOptions = {
input: {
[filenameWithoutExtension]: filePath,
},
};
} else {
viteConfig.build.lib = {
entry: filePath,
fileName: () => filename,
formats: ['es'],
name: filenameWithoutExtension,
};
}
await vite.build(viteConfig);
return outputPath;
}); |
define: {
'process.env.NODE_ENV': '"production"'
}, |
7 tasks
1 task
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
After upgrading to v3 from v2.9 process.env got removed in library mode, defining new variables won't fix the issue.
in dev-mode everything works fine, this only occurs on production build.
react18 entry file in node-modules tries to access
process.env.NODE_ENV
which causes this issuedue to my requirements, I also can't use react as an external package.
this is my config file:
Reproduction
yarn build
and thenthe vite web-component is not loaded and will give the error in the console.
https://stackblitz.com/edit/vitejs-vite-jkfrgb?file=index.html,external-project%2Fsrc%2FApp.js,external-project%2Fpublic%2Findex.html,src%2FLayoutProvider.jsx&terminal=dev
System Info
Used Package Manager
yarn
Logs
Click to expand!
The text was updated successfully, but these errors were encountered: