如何将脚本单独包含在我的构建文件夹中? [英] How to include a script into my build folder separately?
本文介绍了如何将脚本单独包含在我的构建文件夹中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用需要后台脚本(background.js)的Chrome扩展程序.当前,当我npm运行build时,将正常构建build文件夹中的项目.然后,我将background.js复制并粘贴到build文件夹中,这很正常.
I am working on a Chrome extension that requires a background script (background.js). Currently when I npm run build, the project is built as normal in the build folder. I then copy and paste background.js into the build folder, and this works perfectly.
我想要的是在npm运行构建项目时将该脚本自动包含在构建文件夹中.任何指导表示赞赏.
What I want is for this script to be automatically included in my build folder when I npm run build my project. Any guidance is appreciated.
推荐答案
您可以将脚本添加到public
文件夹中,并将此行添加到您的index.html
文件中:
You could add the script to the public
folder and add this line to your index.html
file:
<script src="%PUBLIC_URL%/background.js"></script>
这篇关于如何将脚本单独包含在我的构建文件夹中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文