2016-11-13 60 views
0

的問題是,當我添加一個鏈接組成例如化妝組成鏈接

<Route path="L1/L2" component={Comp}/>

導航到該鏈接時,應用程序無法加載從公用文件夾的資源導致應用程序是從例如加載資源:http://localhost:8080/L1/bundle.js代替http://localhost:8080/bundle.js 我想這是在的WebPack配置有問題,但不能在這裏解決它 是我的WebPack配置:

var config = { 
     devtool: 'eval-source-map', 
     entry: __dirname + "/app/Index.js", 
     output: { 
     path: __dirname + "/public", 
     filename: "bundle.js" 
    }, 
    module: { 
    loaders: [{ 
     test: /\.jsx?$/, 
     exclude: /node_modules/, 
     loader: 'babel', 
     query: { 
     presets: ['es2015','react'] 
     } 
    }] 
    }, 
    devServer: { 
    contentBase: "./public", 
    colors: true, 
    historyApiFallback: true, 
    inline: true 
    } 

所有幫助將不勝感激提前謝謝!

回答

1

它是關於如何在您的包在index.html加載:

  • <script src="bundle.js"></script>相對於當前URL

  • <script src="/bundle.js"></script>是相對於

嘗試第二個版本,它應該工作。

+0

謝謝你工作:) – abderrahmen