简体   繁体   English

reactjs service worker not found.license 文件

[英]reactjs service worker not found .license file

I'm working on two React projects.我正在做两个 React 项目。

In both projects, the manifest.json file is set up correctly and The serviceworker is also registered.在这两个项目中,manifest.json 文件已正确设置,并且 serviceworker 也已注册。

In one of the projects, the question of adding to the home screen is not asked.在其中一个项目中,没有询问添加到主屏幕的问题。

From the research I've done, I've found that a project that doesn't work properly can't find a file in.license format, but in a project that works properly, it's a file with a.license.txt format.从我做的研究中,我发现一个不能正常工作的项目找不到.license格式的文件,但是在一个正常工作的项目中,它是一个.license.txt格式的文件.

What makes the difference between the two files when it is taken from the building project?从建筑项目中获取这两个文件时,有什么区别? How can this problem be solved?如何解决这个问题?

Photo of the project that works properly and displays the install app prompt正常运行并显示安装应用提示的项目照片

正常运行并显示安装应用提示的项目照片

The project photo does not work properly and does not show the install app prompt项目照片无法正常使用,不显示安装应用提示

项目照片无法正常使用,不显示安装应用提示

error message in console控制台中的错误消息

控制台中的错误消息

Finally I found the solution to the problem.最后我找到了解决问题的方法。 If you have ejected the project, you can add a field called extractComments with a false value in the webpack.config.js file in the TerserPlugin section.如果您已退出项目,则可以在TerserPlugin部分的 webpack.config.js 文件中添加一个名为extractComments的字段,其值为 false。 If you have not ejected the project, you can solve this problem by creating a webpack.config.js file and adding the Terser module with the default settings and adding the extractComments field with a false value.如果您还没有弹出项目,您可以通过创建 webpack.config.js 文件并使用默认设置添加 Terser 模块并添加具有 false 值的extractComments字段来解决此问题。 The following links may be helpful in understanding and resolving the issue.以下链接可能有助于理解和解决问题。

license-to-kill-your-PWA 杀死你的 PWA 的许可证

terser-plugin 简洁的插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM