2016-11-27 76 views
3

我將基於React Slingshot樣板的編譯節點站點部署到Github頁面。通過npm start可以在本地運行。如何調試404發佈節點站點到Github頁面?

但是,當我使用babel編譯文件並提交到我的github頁面庫。該網站爲main.c5ec540e041525c6d312.js文件返回了404,儘管我可以看到它位於git存儲庫中。 (從鏈接致力於公司名稱等等,這些將不低於工作)

從GitHub創建的鏈接是:

https://pages.github.mycompanyname.com/DDM/index.html

而404我得到的是:

https://pages.github.mycompanyname.com/main.c5ec540e041525c6d312.js/

我嘗試刪除並重新添加回購建議這裏無濟於事:

How to fix page 404 on Github Page?

問: 如何調試404發佈節點網站Github的頁面?

這是babel編譯後dist文件夾的內容。然後我把它推到了Github Pages repo上,它可以從主分支自動構建網站。但給人的main.js文件404:

enter image description here

我曾嘗試編譯之前也改變Index.js的browserHistoryhashHistory。作爲在GitHub上的網頁問題指出browserHistory使用絕對鏈接,而後者則沒有:

import React from 'react'; 
import ReactDom from 'react-dom'; 
import Routes from './routes'; 
import {Router, hashHistory} from 'react-router'; 
import './styles/styles.scss'; 


import appStore from './reducers'; 
import { Provider } from 'react-redux'; 
import { createStore } from 'redux'; 

let store = createStore(appStore); 

require('./images/favicon.ico'); 
let element = document.getElementById('app'); 

ReactDom.render(
    <Provider store={store}> 
     <Router history={hashHistory} routes={Routes.routes} /> 
    </Provider>, element); 

document.body.classList.remove('loading'); 

這是編譯index.js文件的鏈接:

http://hastebin.com/sipimizazu.xml

也要看webpack專業版配置編譯。我看到公共路徑設置如下:

export default { 
    resolve: { 
    extensions: ['', '.js', '.jsx'] 
    }, 
    debug: true, 
    devtool: 'source-map', // more info:https://webpack.github.io/docs/build-performance.html#sourcemaps and https://webpack.github.io/docs/configuration.html#devtool 
    noInfo: true, // set to false to see a list of every file being bundled. 
    entry: path.resolve(__dirname, 'src/index'), 
    target: 'web', // necessary per https://webpack.github.io/docs/testing.html#compile-and-test 
    output: { 
    path: path.resolve(__dirname, 'dist'), 
    publicPath: '/', 
    filename: '[name].[chunkhash].js' 
    }, 
+0

你把它放在GH-頁面分支? –

+0

不,它是在主人和頁面生成器被設置爲從中拉。 –

+0

你確定該文件簽入git? –

回答

0

更改webpack配置中的publicPath修復了404錯誤。正如我的GitHub的頁面進行了位於.../DDM/

我更新了配置以下內容:

output: { 
    path: path.resolve(__dirname, 'dist'), 
    publicPath: '/DDM/', 
    filename: '[name].[chunkhash].js' 
    }, 
+1

嘿,布賴恩,我在將基於反應彈弓的項目部署到GitHub頁面時遇到了類似的問題。你能否提供更多有關你如何運作的信息?它看起來像我有相同的設置,但我仍然得到404錯誤和不正確的路徑。你有我可以參考的示例項目嗎? – Logan

+0

嗨你的存儲庫的Github Pages組織的名稱是什麼?在webpack.env.config.js文件中,publicPath的值又是什麼? Github頁面使用此公共路徑來查找index.js文件,您可能會得到404,因爲路徑與您的Github組織的名稱不匹配。 –

+0

我正在嘗試發佈到https://lwilli.github.io/WeatherCompare/。 React Slingshot repo中沒有webpack.env.config.js文件...我一直在將webpack.config.prod.js中的output.publicPath值設置爲'/ WeatherCompare /',但我無法獲取任何工作路線 - 只有主頁有效。 – Logan

相關問題