[英]React app changes not updaiting after running npm run build
I have a react app with the following file structure:我有一个具有以下文件结构的反应应用程序:
When I run npm run build
the app compiles everything using webpack
and npm gives me the following output:当我运行
npm run build
应用程序编译所有使用webpack
和 npm 给我以下 Z78E6221F6393D4356868:
In the output (build folder), it creates an asset-manifest.json
file, containing the newly created files:在 output(构建文件夹)中,它创建了一个
asset-manifest.json
文件,其中包含新创建的文件:
{
"files": {
"main.css": "/static/css/main.607e5368.chunk.css",
"main.js": "/static/js/main.08012c8a.chunk.js",
"main.js.map": "/static/js/main.08012c8a.chunk.js.map",
"runtime~main.js": "/static/js/runtime~main.a8a9905a.js",
"runtime~main.js.map": "/static/js/runtime~main.a8a9905a.js.map",
"static/css/2.8643d4fb.chunk.css": "/static/css/2.8643d4fb.chunk.css",
"static/js/2.1aae919f.chunk.js": "/static/js/2.1aae919f.chunk.js",
"static/js/2.1aae919f.chunk.js.map": "/static/js/2.1aae919f.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.ca81004b99ff7fc6f769d98332234f01.js": "/precache-manifest.ca81004b99ff7fc6f769d98332234f01.js",
"service-worker.js": "/service-worker.js",
"static/css/2.8643d4fb.chunk.css.map": "/static/css/2.8643d4fb.chunk.css.map",
"static/css/main.607e5368.chunk.css.map": "/static/css/main.607e5368.chunk.css.map",
"static/media/index.scss": "/static/media/slick.f97e3bbf.svg"
}
}
However, if I go into my browser the react app doesn't update and keeps using the old filenames.但是,如果我 go 进入我的浏览器,反应应用程序不会更新并继续使用旧文件名。 If I go to the network inspector I can see that the files are loaded with
200 OK (from ServiceWorker)
.如果我 go 到网络检查员,我可以看到文件已加载
200 OK (from ServiceWorker)
。
Why are the newly genrated files not being used in the new index.html?为什么新生成的文件没有在新索引中使用。html?
I've tried clearing my cache, using a clean installation of the template, using another browser, using incognito mode,...我尝试清除缓存,使用模板的全新安装,使用另一个浏览器,使用隐身模式,...
It is due to service worker.这是由于服务人员。 Unregister your service worker to show updated content
取消注册您的服务人员以显示更新的内容
In your index.js or whatever is main file in react app在您的 index.js 或任何反应应用程序中的主文件中
// import registerServiceWorker from './registerServiceWorker'; // comment this line
import { unregister } from './registerServiceWorker';
Comment registerServiceWorker()
评论
registerServiceWorker()
// registerServiceWorker()
unregister();// add this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.