Skip to content
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

关于vitePress打包时报错这个问题? #787

Open
a1067111756 opened this issue Feb 29, 2024 · 1 comment
Open

关于vitePress打包时报错这个问题? #787

a1067111756 opened this issue Feb 29, 2024 · 1 comment

Comments

@a1067111756
Copy link

环境:
"vitepress": "1.0.0-rc.44",
"vue": "3.3.4",
"vite": "^4.3.9",
"vue-cropper": "^1.1.1",

复现情况:
开发环境:一切正常,功能完整
正式环境:(package.json启用了type: "module")
1. 打包时出现报错,如下截图,从报错可以看出是打包的格式问题,不支持ES module。
微信截图_20240229092355
2. 然后换个思路,在vite -> ssr -> noExternal设置中将vue-cropper加入非外部化来避免es转换,继续打包出现如下报错
ssr: {
noExternal: ['vue-cropper']
}

微信截图_20240229092749
从报错中可以看出是代码中使用了File对象,vitepress目标产物是在node环境中,没有提供这些全局对象,导致报错,这个地方需要处理

    3.  暂时解决方案:在打包代码vue-cropper.es.js中将使用File的声明去掉,打包成功

11
13

@xyxiao001
Copy link
Owner

我修复下这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants