create-react-app: <script> 标签文件被替换为 index.html

huangapple go评论87阅读模式
英文:

create-react-app: <script> tag files are replaced with index.html

问题

我在尝试在我的create-react-app中包含<script>标签时,看到了与webpack相关的行为。

当我包含一个脚本标签(例如<script src="/public/myjs.js" />)时,实际返回的是index.html。是否有需要更改的打包或路由规则,以确保应用程序实际包含我所请求的脚本?

英文:

I'm seeing behavior that seems webpack related while trying to include &lt;script&gt; tags in my create-react-app.

When I include a script tag (like &lt;script src=&quot;/public/myjs.js&quot; /&gt;), what is instead returned is index.html. Is there a packaging or routing rule I need to change to convince the app to actually include the script I am asking for?

create-react-app: <script> 标签文件被替换为 index.html

答案1

得分: 1

在标准的Create React App(CRA)设置中,你在index.html文件中包含的 :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定