【发布时间】:2021-09-26 07:35:16
【问题描述】:
我使用 Webpack 作为我的 Reactjs 应用程序的模块捆绑器。使用 spring boot 作为后端服务。在开发服务器和生产服务器上的 Firefox 浏览器上都可以。您可以从此处检查生产版本: https://fullstackapp.io
但它不适用于 chrome 浏览器,它在生产和开发环境中都显示完全像这样的空白页面。我该如何克服这种情况?
我的 wepback.config.js 是:
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: "development",
entry: "/src/index.jsx",
output: {
path: path.resolve(__dirname, "build"),
publicPath: '/',
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(png|jpg|jpeg|gif|svg|ico|ttf|eot|woff)$/,
exclude: /node_modules/,
use: ["file-loader"]
},
]
},
resolve: {
extensions: [".jsx", ".js"]
},
devServer: {
port: 3000,
static: {
directory: path.join(__dirname, 'public'),
},
hot: true,
historyApiFallback: true,
proxy: {
'/api': {
target: 'http://localhost:8080',
secure: false
}
},
},
watchOptions: {
ignored: /node_modules/
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
title: "Hot Module Replacement",
template: "/public/index.html"
})
]
}
【问题讨论】:
-
有指示符“1error”但错误本身似乎被过滤掉了
-
这只是一个 RestAPI 响应。它只是检查用户是否经过身份验证。
-
刚刚在 chrome 中打开了您的链接。渲染得很好。没有错误。
-
请添加一些可重现的代码,人们很难使用缩小的代码。
-
有时它可以在 Chrome 中工作,但当您在浏览器上硬重新加载时并不总是这样。请用手机确认。
标签: reactjs webpack react-router-dom