[英]React app not working on AWS S3 server inside a static index.html file
[英]Dynamically set the file path for static files in the index.html file in a React app via a JSON file
我正在尝试在我的 create-react-app 的 index.html 文件中动态设置 static 文件(js & css)的文件路径,以便它们可以根据我在设置中设置的内容指向不同的子目录.json 文件。
示例:如果我在 settings.json 文件中设置 base_url,如下所示:
{
"BASE_PATH_URL": "/subdirec1"
}
我希望我的 index.html 文件中的文件路径是这样的:
<script src="/subdirec1/static/vendors/js/core/jquery-3.2.1.min.js" type="text/javascript"></script>
如果有人可以在这里帮助我,我将不胜感激。 谢谢!
If you're using webpack, you can use webpack variables that you can set within the webpack config object, which themselves come from a.json/.js file.
如果您使用的是 webpack, 这是您可以使用的示例!
警告:在阅读之前不要使用下面的命令,因为它会弄乱你可能还不理解的文件!
由于您使用的是 create-react-app,我认为它在引擎盖下使用了 webpack,但您需要npm run eject
以更完整地访问其配置!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.