从git repo(ReactJS,Nginx)拉出后死亡的白屏 [英] Whitescreen of death after pulling from git repo (ReactJS, Nginx)
问题描述
每当我从master分支执行git pull到服务器上时,我所有的React文件似乎都消失了,屏幕变成白色.
Whenever I perform a git pull from my master branch onto my server, all my React files seem to just disappear and the screen turns white.
我发现的临时解决方法是:
The temporary workarounds I had found were:
- 删除浏览器Cookie,缓存和网站历史记录,然后关闭浏览器,然后重试.
- 删除node_modules,npm重新安装所有react依赖项
过一会儿,该站点重新出现,并且一切正常,直到在几次请求请求之后的下一次,问题再次出现.
After a while, the site reappears and everything works as normal until the next time after a few pull requests, the problem appears again.
我在任何浏览器上使用的任何控制台都不会显示任何错误消息. 经过2个多星期的谷歌搜索,我似乎找不到与该问题有关的任何东西.
Any console I use on any browser shows no error messages at all. After 2+ weeks of googling around, I can't seem to find anything that relates to this issue.
这是我的规格:
Ubuntu 16.04服务器 框架:React 16.2.0 webpack 1.12 Nginx版本:Nginx/1.10.3(Ubuntu) git版本2.7.4
Ubuntu 16.04 server Framework: React 16.2.0 webpack 1.12 nginx version: nginx/1.10.3 (Ubuntu) git version 2.7.4
我的webpack设置(为清楚起见,我使用以下命令编译了所有的react文件):
My webpack settings (for clarity, I compile all my react files with the command):
node_modules/.bin/webpack --config webpack.local.config.js
(本地)
var path = require("path")
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')
var config = require('./webpack.base.config.js')
config.devtool = "#eval-source-map"
config.plugins = config.plugins.concat([
new BundleTracker({
filename: './webpack-stats-local.json'
}),
])
config.module.loaders.push({
test: /\.js[x]?$/,
exclude: /node_modules/,
loaders: ['react-hot-loader/webpack', 'babel'],
})
module.exports = config
(基本)
var path = require("path")
var webpack = require('webpack')
module.exports = {
context: __dirname,
entry: {
App1: './path/to/App1/',
App2: './path/to/App2/',
// ...
App10: './path/to/App10/',
vendors: ['react'],
},
output: {
path: path.resolve('./backend/static/bundles/local/'),
filename: "[name]-[hash].js"
},
externals: {
"gettext":"gettext",
"django":"django",
}, // add all vendor libs
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
],
module: {
loaders: []
},
resolve: {
modulesDirectories: ['node_modules', 'bower_components'],
extensions: ['', '.js', '.jsx']
},
}
任何帮助将不胜感激
推荐答案
我通过将Webpack更新到版本4 +更新了我使用的依赖关系,同时摆脱了我不使用的依赖关系,解决了这个问题.
I solved this problem by updating Webpack to version 4 + updating the dependencies i used while getting rid of the ones i don't use.
这篇关于从git repo(ReactJS,Nginx)拉出后死亡的白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!