可加载的组件+ SSR+ WebPack 5-重复main.js

发布于 2025-01-31 10:52:54 字数 878 浏览 2 评论 0原文

我重构由“ Create-React-App”制作的旧应用程序。我想添加可加载的组件库,并且所有内容都可以使用,直到我添加 extractor.getScriptTags()为index.html。

添加提取器导致webpack

头部 in index.html中生成的main.js文件的重复:

<link data-chunk="main" rel="preload" as="script" href="/main.js">
<link data-chunk="main" rel="stylesheet" href="/static/css/main.52fc8570.css">
<script defer="defer" src="/main.js"></script>
<link href="/static/css/main.52fc8570.css" rel="stylesheet">

正文部分通过extractor.getScripttags()注入脚本

<script async data-chunk="main" src="/main.js"></script>

在构建应用程序开始时生成的片段

<script defer="defer" src="/main.js"></script>
<link href="/static/css/main.52fc8570.css" rel="stylesheet">

是否可以通过webpack禁用注入生成的main.js?

I refactor an old application made by 'create-react-app'. I wanted to add the loadable components library and everything worked until I added extractor.getScriptTags() to index.html.

Adding the extractor resulted in the duplicate of the generated main.js file by the webpack

head section in index.html:

<link data-chunk="main" rel="preload" as="script" href="/main.js">
<link data-chunk="main" rel="stylesheet" href="/static/css/main.52fc8570.css">
<script defer="defer" src="/main.js"></script>
<link href="/static/css/main.52fc8570.css" rel="stylesheet">

body section with script injected via extractor.getScriptTags()

<script async data-chunk="main" src="/main.js"></script>

the fragment generated at the beginning of building the application

<script defer="defer" src="/main.js"></script>
<link href="/static/css/main.52fc8570.css" rel="stylesheet">

Is it possible to disable injection of the generated main.js by the webpack?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文