简体   繁体   English

如何在使用 vite 构建的 vue.js 站点中包含 dagre/graphlib

[英]How can I include dagre/graphlib in a vue.js site built with vite

["

I want to include dagre (or graphlib, get same issues) in a vite based vue project but hitting issues at either runtime or build time depending on options I've tried.<\/i>我想在基于 vite 的 vue 项目中包含 dagre(或 graphlib,得到相同的问题),但在运行时或构建时遇到问题,具体取决于我尝试过的选项。<\/b><\/p>

➜ npm create vite@latest
✔ Project name: … demo
✔ Select a framework: › vue
✔ Select a variant: › vue

A workaround is to add an option to the CommonJS compilation module, it's discussed on GitHub: https://github.com/vitejs/vite/issues/5759#issuecomment-1034461225一种解决方法是向 CommonJS 编译模块添加一个选项,它在 GitHub 上进行了讨论: https ://github.com/vitejs/vite/issues/5759#issuecomment-1034461225

Vite's config file should be changed like so: Vite 的配置文件应该这样更改:

build: {
    commonjsOptions: {
        ignoreTryCatch: false
    }
}

Also be sure to remove the CommonJS Rollup plugin.还要确保删除 CommonJS Rollup 插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM