没有构建文件夹

发布于 2025-02-14 02:15:27 字数 782 浏览 0 评论 0原文

我使用的是包裹捆绑器,而不是使用npm run build-prod而不是npm run build build,但它不会创建构建文件夹,而是他们所有这些都在一个DIST文件夹中,因此我更改了package.json中的部署脚本。页-D构建“ ,它将出现一个错误,说构建脚本丢失了,在我尝试将其部署到Git Hub页面后,但我得到了一个空屏幕

 "scripts": {
 "predeploy": "npm run build-prod",
 "deploy": "gh-pages -d dist",
 "clean": "rm dist/bundle.js",
 "start": "parcel src/index.html",
 "build-prod": "parcel build src/index.html"
},
"dependencies": {
 "node-sass": "^7.0.1",
 "react": "^18.2.0",
 "react-dom": "^18.2.0",
 "react-router-dom": "^6.3.0"
},
"devDependencies": {
 "@babel/core": "^7.18.5",
 "@babel/preset-env": "^7.18.2",
 "@babel/preset-react": "^7.17.12",
 "gh-pages": "^4.0.0",
 "parcel-bundler": "^1.12.5",
 "prettier": "^2.7.1"
}

I'm using a parcel bundler instead of a react-scripts which uses npm run build-prod instead of npm run build but it doesn't create a build folder instead they all in a dist folder so i changed the deploy script in the package.json to "deploy": "gh-pages -d dist" instead of the standard "deploy": "gh-pages -d build" which will give an error saying build script is missing , after i tried deploying this to git hub pages but i get an empty screen

 "scripts": {
 "predeploy": "npm run build-prod",
 "deploy": "gh-pages -d dist",
 "clean": "rm dist/bundle.js",
 "start": "parcel src/index.html",
 "build-prod": "parcel build src/index.html"
},
"dependencies": {
 "node-sass": "^7.0.1",
 "react": "^18.2.0",
 "react-dom": "^18.2.0",
 "react-router-dom": "^6.3.0"
},
"devDependencies": {
 "@babel/core": "^7.18.5",
 "@babel/preset-env": "^7.18.2",
 "@babel/preset-react": "^7.17.12",
 "gh-pages": "^4.0.0",
 "parcel-bundler": "^1.12.5",
 "prettier": "^2.7.1"
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆悲凉 2025-02-21 02:15:27

根据在这里您需要指定- dist-- dir标志。

将您的更改为“ build-prod”脚本:

"build-prod": "parcel build src/index.html --dist-dir build"

现在,您的包裹构建的输出目录将转到build> build> build而不是dist>,因此您可以将“部署”脚本更改回:

"deploy": "gh-pages -d build"

According the the Parcel docs here, you need to specify the --dist-dir flag.

Change your "build-prod" script to this:

"build-prod": "parcel build src/index.html --dist-dir build"

Now the output directory for your parcel build will go to build instead of dist so you can change your "deploy" script back to this:

"deploy": "gh-pages -d build"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文