Mam następujący plik WebPack config:React-router z BrowserRouter/browserHistory nie działa na odświeżeniu
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
var config = {
entry: [
APP_DIR + '/config/routes.jsx',
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8080'
],
output: {
publicPath: 'http://localhost:8080/src/client/public/'
},
module : {
loaders : [
{
test: /\.jsx?$/,
loader: 'babel-loader',
include: APP_DIR,
exclude: /node_modules/,
query: {
presets: ['es2015']
}
},
{
test: /\.scss$/,
loaders: [ 'style', 'css', 'sass' ]
},
{
test: /\.json$/,
loader: "json-loader"
}
]
}
};
module.exports = config;
wszystko staram się zrobić to uruchomić mojej aplikacji na localhost, jednak gdy uderzę " http://localhost:8080/src/client/home "(jak na moje routes.jsx i po uruchomieniu WebPACK-dev-serwer)
import React from 'react';
import { Route, Router, browserHistory } from 'react-router';
import ReactDOM from 'react-dom';
import Wrapper from './../components/wrapper.jsx';
import Home from './../components/home.jsx';
import Projects from './../components/projects.jsx';
import SingleProject from './../components/projectContent/singleProject.jsx';
import About from './../components/aboutUs.jsx'
ReactDOM.render((
<Router history={browserHistory} >
<Route path="/" component={Wrapper} >
<Route path="home" component={Home} />
<Route path="projects" component={Projects} />
<Route path="projects/:id" component={SingleProject} />
<Route path="about" component={About} />
</Route>
</Router>
), document.getElementById('app'));
uzyskać
"Can not get/src/klient/home".
WebPack-dev-serwer służy jedynie pliki w katalogu build. W twoim przypadku jest to folder 'public' wewnątrz' src/client'. Dlatego też nie znaleziono '/ src/client/home'. –
Spróbuj odwiedzić http: // localhost: 8080/home –