gh-pages 仅发布背景图片
2020-05-10
187
我是 gh-pages 的新手,今天部署了我的第一个网站。 但是,只显示背景图像: https://sabago.github.io/sabago-portfolio/
我的仓库: https://github.com/sabago/sabago-portfolio
在谷歌搜索后,我发现: 将 React 应用程序上传到 gh-pages 后,只显示背景。 但这不是我的确切问题。
一切正常localhost。
任何帮助都非常感谢。
注意:我应该补充一点,我在控制台中看到一个错误。我不确定它是否相关,但它指向我在 tsconfig (esnext) 中的编译器模块。
main.9af833d9.chunk.js:1 Uncaught ReferenceError: exports is not defined
at Module.21 (main.9af833d9.chunk.js:1)
at a ((index):1)
at Object.12 (App.tsx:4)
at a ((index):1)
at Module.44 (main.9af833d9.chunk.js:1)
at a ((index):1)
at Object.14 (main.9af833d9.chunk.js:1)
at a ((index):1)
at t ((index):1)
at Array.r [as push] ((index):1)
我的 tsconfig
"compilerOptions": {
"target": "es6",
"module": "esnext",
"sourceMap": true,
"jsx": "react",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": [
"src"
]
}
package.JSON
{
"homepage": "https://sabago.github.io/sabago-portfolio/",
"name": "sabago",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@types/react": "^16.9.34",
"@types/react-burger-menu": "^2.6.1",
"@types/react-dom": "^16.9.7",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"typescript": "^3.8.3",
"webpack-cli": "^3.3.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages master -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.2.0",
"webpack-cli": "^3.3.11"
}
}
2个回答
您已安装
gh-pages
软件包,因此要部署您的应用,您只需从应用目录中的命令行运行以下命令:
yarn deploy
这会将您的
build
目录推送到 github pages。如果您尚未构建应用,则需要先构建它:
yarn build && yarn deploy
Nick
2020-05-10
我不确定这个问题的实际解决方案是什么。我通过从头开始解决了这个问题,但这次我在创建 React 应用之后部署,而不是在编码之前。
Sandra
2020-05-10