-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
使用 vite 打包出错 #2539
Labels
bug
Something isn't working
Comments
https://github.com/chnejohnson/vue3-dapp-starter 是这个,我可以跑起来,这里面启用了 |
他的 {
"name": "vue3-dapp-starter",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"buffer": "^6.0.3",
"ethers": "^5.5.2",
"process": "^0.11.10",
"util": "^0.12.4",
"vue": "^3.2.16",
"vue-dapp": "^0.4.6",
"vue-router": "4"
},
"devDependencies": {
"@rollup/plugin-inject": "^4.0.3",
"@vitejs/plugin-vue": "^1.9.2",
"typescript": "^4.4.3",
"vite": "^2.6.0",
"vite-plugin-windicss": "^1.4.8",
"windicss": "^3.1.8"
}
} |
有解决方案吗,我这边也是报错Uncaught ReferenceError: exports is not defined |
也遇到了这个问题,我是这么解决的,具体是在上面回答的transformMixedEsModules之外排除 lodash-es,完整的 build 配置 build: {
rollupOptions: {
plugins: [nodePolyfills()]
},
commonjsOptions: {
transformMixedEsModules: true,
exclude: [
'node_modules/lodash-es/**',
'node_modules/@types/lodash-es/**',
],
},
} 以上路径是针对 yarn 的,其他的路径可能不同 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TuSimple/naive-ui version (版本)
2.26.0
Vue version (Vue 版本)
3.2.31
Browser and its version (浏览器及其版本)
Firefox 97.0.1
System and its version (系统及其版本)
macOS 12.2
Node version (Node 版本)
16.14.0
Reappearance link (重现链接)
https://github.com/MetaplasiaTeam/castable-nft-web
Reappearance steps (重现步骤)
yarn build && yarn preview
Expected results (期望的结果)
正常显示界面
Actual results (实际的结果)
Uncaught ReferenceError: exports is not defined
这个报错是在
lodash-es
上面,我使用 yarn 查询发现只有这个 UI 库依赖了我有开启转换 es 模块的选项,如下
因为我要使用一部分 web3 的东西,所以需要开启,参看 Failed to serve on production: Uncaught ReferenceError: require is not defined #20 ,可以看到配置有注释,我尝试排除这个模块的转换也没有用。我想知道我应该如何配置,或者放弃 vite。
Remarks (补充说明)
exports is not defined #7128 这里有 debug 日志
The text was updated successfully, but these errors were encountered: