我有一个使用过
create-react-app
的 React 项目,现在我开始了解使用 parcel
的优势,所以现在我想使用 parcel
来构建项目的其余部分。
我安装了parcel作为开发依赖项并启动了服务器,它说index.html无法访问,因为我添加了启动脚本
"start": "parcel ./src/index.html"
但现在又出现了另一个错误
Server running at http://localhost:1234
🚨 Build failed.
@parcel/core: Failed to resolve '%PUBLIC_URL%/logo.svg' from './public/index.html'
@parcel/resolver-default: Cannot load file './%PUBLIC_URL%/logo.svg' in './public'.
这是 GitHub 存储库:https://github.com/olifarhaan/griha-milan
这是实时链接,以防您想检查:https://griha-milan.vercel.app/
我尝试添加
/logo.svg
而不是 ./%PUBLIC_URL%/logo.svg
。另外,我在 index.html 中使用 env 变量作为标题和描述。我无法弄清楚如何在那里显示环境变量。
如果是我,我会创建一个全新的
parcel
项目,然后将 src
和其他资产复制到新项目中。也将 .git
复制过来,然后您就拥有了现有项目的克隆,但位于新的地块项目中。避免携带任何与 CRA 相关的元素。