我正在构建一个 React 应用程序。我安装了 aws-amplify @aws-amplify/ui-react,然后更新我的 vite.config.ts 如下:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
define: {
'process.env': process.env,
'global': {}
},
plugins: [react()],
resolve: {
alias: [
{
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, "");
},
},
{
find: './runtimeConfig', replacement: './runtimeConfig.browser',
}
],
},
})
然而,在这样做之后,我运行了 npm run build,它无法完成,因为 Contentful dependancy 在项目中崩溃了,并显示以下消息: '无法从“node_modules/contentful/dist/es-modules/contentful.js”解析“./create-{}-options”
我一直在寻找没有成功的解决方案。
有谁知道发生了什么或有什么想法可以帮助解决这个问题? 预先感谢您的帮助。