我用webpack创建了一个react应用程序,并试图将其部署到google app引擎。此应用程序没有服务器,一切都在浏览器中完成。我之前已经成功部署了简单的react应用程序,但是我认为webpack的切入点现在让我头疼。
我的应用程序已成功部署,但是导航到URL时,出现502错误的网关错误。当查看$gcloud app logs read
时,我没有看到任何问题,我的应用已成功编译和构建,并且Google Cloud Console中的任何日志都无济于事。我尝试将所有devDependencies移至依赖项。
我的webpack配置:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: './src/index.js',
mode: 'development',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: [
'@babel/env'
]
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|otf)$/,
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: '/dist/',
filename: 'bundle.js'
},
devServer: {
contentBase: path.join(__dirname, 'public/'),
port: 8080,
publicPath: 'http://localhost:8080/dist/',
hot: true
},
devtool: "source-map",
plugins: [new webpack.HotModuleReplacementPlugin()]
};
app.yaml:
# [START app_yaml]
env: flex
runtime: nodejs
# [END app_yaml]
package.json:
{
"name": "my-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --mode development",
"build": "webpack --config webpack.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"css-loader": "^1.0.0",
"d3": "^5.11.0",
"file-loader": "^4.2.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-masonry-css": "^1.0.12",
"style-loader": "^0.23.0",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.8.0"
},
"dependencies": {
"bootstrap": "^4.3.1",
"react-hot-loader": "^4.3.11",
"webpack-dev-server": "^3.8.0",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.1",
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"css-loader": "^1.0.0",
"d3": "^5.11.0",
"file-loader": "^4.2.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-masonry-css": "^1.0.12",
"style-loader": "^0.23.0"
}
}
答案 0 :(得分:0)
如果所有设置均正确,则可能的原因之一是scalability。如果不是扩展性问题,您是否有任何支持包/免费试用版?我建议您直接在support center中打开支持凭单,否则,您可以通过Google Issue Tracker与Google联系,因为5XX错误可能是由多种原因引起的,因此很难通过SO进行故障排除。< / p>