-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
用vue构建web-components组件库,输出dist时,如果没有将vue外部化,那么其他vue项目引入时,会破坏热更新。 #13202
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
Comments
可能是组件库包含 vue 会导致项目里面的 VUE_HMR_RUNTIME 被覆盖,引起 HMR 失效。 |
原来是这样。 但我开发web-components组件库,这个需要依赖vue。为了方便其他框架引入使用,才需要把vue打进组件库。否则别人需要同时导入我的组件库和vue包 这个有什么好的解决办法吗?大佬 |
我暂时通过输出两个版本,一个外部化vue,一个非外部化vue解决了。 希望vue团队能修复这个问题,感谢 |
a workaround export default defineConfig(({ command }) => {
const config: UserConfig = {
// the existing config
};
if (command === 'build') {
config.define = {
...config.define,
// trim Vue HMR code
'process.env.NODE_ENV': JSON.stringify('production')
};
}
return config;
}); |
牛的,大佬!完美解决 |
可以这么理解吗, 大佬: |
true |
Vue version
3.5.13
Link to minimal reproduction
https://github.com/xinnian999/arto-ui
Steps to reproduce
pnpm i
pnpm build 用vite+vue构建web-components组件库(这一步并没有外部化vue)
pnpm dev 运行一个vue项目并引入了上一步构建的dist
这时候修改play/vue下的代码,热更新会失效
What is expected?
期望即使我将vue构建到了组件库dist里,别人引入我的组件库也不会破坏vue的热更新
What is actually happening?
System Info
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: