This repository was archived by the owner on Sep 20, 2024. It is now read-only.
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
CImage and CAvatar depend on process.browser
, not working with Vite #434
Open
Description
Describe the bug
CImage and CAvatar depend on process.browser
which is causing problems with Vite (using vite-plugin-vue2
)
To Reproduce
Steps to reproduce the behavior:
- Set up a Vite project with
vite-plugin-vue2
and @chakra-ui/vue - Add a CImage or CAvatar with a valid
src
- Image does not appear at all
- See error in console
Expected behavior
I expect CImage and CAvatar (and Chakra UI Vue overall) to work in a variety of
Desktop
- OS: macOS 10.15.7
- Browser: Chrome v90.0.4430.212, Brave, Safari
Additional context
CImage and CAvatar appear to be the only components using process.browser
:
https://github.com/chakra-ui/chakra-ui-vue/search?q=process.browser&type=
I have a workaround for a custom polyfill in my main.js
:
if (typeof process === 'undefined' && typeof window.process === 'undefined') {
window.process = {
browser: typeof window !== 'undefined'
}
}
My understanding is that process.browser
is a webpack-centric approach, whereas window !== 'undefined' is more universal.