没有构建文件夹
我使用的是包裹捆绑器,而不是使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据在这里您需要指定
- dist-- dir
标志。将您的
更改为“ build-prod”
脚本:现在,您的
包裹构建的输出目录
将转到build> build> build
而不是dist>
,因此您可以将“部署”
脚本更改回:According the the Parcel docs here, you need to specify the
--dist-dir
flag.Change your
"build-prod"
script to this:Now the output directory for your
parcel build
will go tobuild
instead ofdist
so you can change your"deploy"
script back to this: