我正在尝试使用ReactJS前端启动一个FeathersJS应用程序。在开发过程中,使用
目前,这是我的目录结构:
在
很遗憾,这完全不起作用。以下是我的
webpack-dev-middleware
和webpack-hot-middleware
,我应该能够简单地将所有这些webpack内容扩展到Feathers应用程序中。但是问题在于,每当我从webpack获取js文件时,总是会得到一个Feathers 404页面。目前,这是我的目录结构:
/feathers/public/index.html
/feathers/src/app.js
/react/src/index.js
/react/webpack.config.js
/react/develop.js
/feathers/src/app.js
是默认的feathers应用程序,它从public文件夹提供静态文件。
.use('/', serveStatic( app.get('public') ))
在
/react/develop.js
中,我正在要求使用Feathers应用程序,并使用webpack中间件进行扩展。const app = require('../feathers/src/app');
const config = require('./webpack.config');
const path = require('path');
const webpack = require('webpack');
var compiler = webpack(config);
app.use(require('webpack-dev-middleware')(compiler, {
publicPath: '/',
stats: {colors: true},
}));
app.use(require('webpack-hot-middleware')(compiler));
const port = app.get('port');
const server = app.listen(port);
server.on('listening', () =>
console.log(`Feathers application started on ${app.get('host')}:${port}`)
);
很遗憾,这完全不起作用。以下是我的
/react/webpack.config.js
参考资料。var webpack = require("webpack")
module.exports = {
devtool: 'source-map',
entry: [
'webpack-hot-middleware/client',
'src/index.js'
],
output: {
path: '/',
filename: "bundle.js",
},
module: {
loaders: [
{ test: /\.js$/, loader: "babel", exclude: /node_modules/, query: { presets: ['es2015', 'react', 'stage-0'] } },
{ test: /\.(svg|png|jpe?g|gif|ttf|woff2?|eot)$/, loader: 'url?limit=8182' },
]
},
resolve: {
root: [
__dirname,
__dirname + '/src',
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
]
}
并且 /feathers/public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>React App</title>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>
我已经尝试过调整publicPath的设置,但没有成功。有什么办法可以让这个工作起来吗?我已经花了整整两个小时在这上面,却一无所获。 这是我正在使用的repo的链接,以便提供更多背景信息。