我创建了一个React应用程序,并使用webpack对其进行了捆绑。现在,我正在尝试在heroku上部署该应用程序。构建成功,但是当我尝试打开链接时,出现“应用程序错误”。是否需要在react应用的根级别上将server.js文件放入heroku上的delpoy。
我已经修改了我的webpack,我认为还可以,但是仍然是相同的错误。
//这是我的webpack.common.js
const webpack = require("webpack");
module.exports = {
entry: "./index.jsx",
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
options: { presets: ["@babel/env"] }
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
]
},
resolve: { extensions: ["*", ".js", ".jsx"] },
output: {
path: path.resolve(__dirname, "dist/"),
publicPath: "/dist/",
filename: "bundle.js"
},
plugins: [new webpack.HotModuleReplacementPlugin()]
}
// webpack.dev.js
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common');
module.exports = merge(common, {
mode:'development',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, "public/"),
port: 3000,
publicPath: "http://localhost:3000/dist/",
hot: true
}
});
I expect the app to get deployed on heroku but I am getting application error.