有没有办法将Firebase托管添加到利用webpack的React项目?具体来说,我正在尝试将其添加到https://github.com/mxstbr/react-boilerplate
这是我的firebase.json文件
{
"hosting": {
"firebase": "name",
"public": "app",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我打电话时firebase serve页面是空的.但是,如果我这样做npm start的应用程序正常工作.因此,JS/React代码没有被注入index.html,即
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome to Firebase Hosting</title>
</head>
<head>
<!-- The first thing in any HTML file should be the charset -->
<meta charset="utf-8">
<!-- Make the page mobile compatible -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Allow installing the app to the homescreen …Run Code Online (Sandbox Code Playgroud) 我正在浏览reactfire github,他们使用mixins.
我以为他们被弃用了?我是落后于时代吗?
我正在用我需要的 Reactfire 提供程序包装 Next 根布局的子级:
import './globals.css';
import { AuthProvider, FirebaseAppProvider } from 'reactfire';
import { auth, firebaseConfig } from '../config/firebase';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<FirebaseAppProvider firebaseConfig={firebaseConfig}>
<AuthProvider sdk={auth}>
{children}
</AuthProvider>
</FirebaseAppProvider>
</body>
</html>
)
}
Run Code Online (Sandbox Code Playgroud)
firebaseConfig是正确的,因为我可以使用该模块成功连接到我的 Firebase 应用程序firebase。
当我运行时npm run dev失败并出现以下错误:
请求模块的导入跟踪:
../node_modules/reactfire/dist/index.js
./src/app/layout.tsx
- error ../node_modules/reactfire/dist/index.js
Attempted import error: 'createContext' is not exported from 'react' (imported as 'f').
Run Code Online (Sandbox Code Playgroud)
我尝试更新 npm,降级到以前的 Reactfire …