0

私のルートが一致し、アプリケーションバンドルSearchUXBundle.jsが第1レベルのルートから正しくロードされます。間違ってlocalhost/dist/SearchUXBundle.jsの代わりにlocalhost/tracker/dist/SearchUXBundle.jsからアプリケーションバンドルをロードしようとしています。イム、...これは行方不明イム相対パスに関連WebPACKの '出力' に設定しわのいくつかの種類であるレスポンスルータのパラメータルートを使用して設定場所からバンドルを提供していません

webpack.configを想定

var path = require('path'); 
var webpack = require('webpack'); 

module.exports = { 
    devtool: 'source-map', 
    devServer: { 
     inline:false, 
     port: 8001, 
     historyApiFallback: true 
    }, 
    entry: { 
    app: ['./src/root.js'] 
    }, 

    output: { 
      path: "/dist", 
      publicPath: '/', 
      filename: '/dist/SearchUXBundle.js' 
    }, 
    module: { 
    loaders: [ 
     { 
     test: /\.js$/, 
     exclude: /node_modules/, 
     loader: 'babel', 
     query: { 
      retainLines: true, 
      cacheDirectory: true 
     } 
     }, 
     { 
     test: /.css$/, 
     loaders: ['style', 'css']  
     }, 
     { test: /\.(png|jpg|jpeg|gif|woff)$/, loader: 'url-loader?limit=8192' }, 
    ] 
    }, 
    resolve: { 
     alias: { 
      __CONFIG__: path.join(__dirname, 'config', process.env.REACT_ENV) 
     } 
    } 
}; 

app.js

... 
const store = createStore(rootReducer, enhancer); 
const history = syncHistoryWithStore(browserHistory, store, { 
    selectLocationState: createSelectLocationState() 
}); 

render(
    <Provider store={store} > 
    <Router history={history}> 
     <Route path="/" component={SearchUXContainer} /> 
     <Route path="tracker/:id" component={EmailTrackerContainer}/> 
     <Route path="thisWorks" component={SearchUXContainer}/> 
    </Router> 
    </Provider>, 
    document.getElementById('app') 
); 
+1

あなたの 'index.html'を含めることができますか?私の最初の推測では、 'index.html'の' SearchUXBundle.js'は絶対的でなければならない相対的なものです。 –

+0

ビンゴ!だから私は間違って "dist/SearchBundle.js"をリンクしていた - 私が見つけたもう一つの問題は、私が不適切にの下に自分のルートを入れ子にしていたことだった。これを回答に転がしたいのであれば、私はそれを受け入れます – steveinatorx

答えて

2

をJS index.htmlファイルのリンクされたバンドルが絶対的であることを確認する必要があります。相対パスの場合、URLに基​​づいて場所が異なり、ネストされたルートは存在しない場所を指します。

<!-- bad --> 
<script src="dist/SearchUXBundle.js"></script> 

<!-- good --> 
<script src="/dist/SearchUXBundle.js"></script> 
関連する問題