我试图让react-router与webpack-dev-server一起工作,但继续得不到Get/SOMEURL.这是因为webpack-dev-server正在查找该特定文件但无法找到它.我希望webpack使用react-router vs搜索文件本身.
我怎么设置它?
我的咕噜声:
'webpack-dev-server': {
options: {
hot: true,
port: 8000,
webpack: webpackDevConfig,
publicPath: '/assets/',
contentBase: './<%= pkg.src %>/'
},
start: {
keepAlive: true,
}
},
Run Code Online (Sandbox Code Playgroud) 我试图用react-hot-loader同webpack-dev-server和react-router,但是当我尝试访问本地主机:3000 /我得到:
Cannot GET /
当然,它在我尝试访问localhost:8000 /时有效.我试图遵循反应热模板,没有成功.
这是我的代码:
server.js
const http = require('http');
const express = require('express');
const consolidate = require('consolidate');
const bodyParser = require('body-parser');
const routes = require('./routes');
const app = express();
app.set('views', 'public/pages'); // Set the folder-name from where you serve the html page.
app.set('view engine', 'html');
app.engine('html', consolidate.handlebars);
app.use(express.static('public')); // Set the folder from where you serve all static files
app.use(express.static('public/dist')); // Set the folder from where you serve …Run Code Online (Sandbox Code Playgroud)