[英]expressjs - serving vendors folder on localhost but not on heroku/otherhost
I'm using expressjs and handlebars to serve webpages. 我正在使用expressjs和把手来提供网页。 All my javascripts are inside the public/javascripts folder and my stylesheets are inside public/stylesheets.
我所有的JavaScript都位于public / javascripts文件夹中,而我的样式表均位于public / stylesheets中。
Loading .css or .js files from inside there works. 从那里加载.css或.js文件是可行的。 But now I have a folder public/vendors/bower_components/ with subfolders inside.
但是现在我有了一个文件夹public / vendors / bower_components /,里面有子文件夹。
On localhost it loads items from inside the vendor folder but not when I serve pages to the public or when I commit it to Heroku. 在localhost上,它从供应商文件夹内加载项目,但当我向公众提供页面或将其提交给Heroku时则不加载。
This is my static folder: 这是我的静态文件夹:
app.use(express.static(path.join(__dirname, 'public')));
This is how I include the JS/css: 这就是我包括JS / css的方式:
<script src="vendors/bower_components/jquery-toast-plugin/dist/jquery.toast.min.js"></script>
<link href="vendors/bower_components/jquery-toast-plugin/dist/jquery.toast.min.css" rel="stylesheet" type="text/css">
I already tried adding a forward slash to vendors but it still doesn't get served. 我已经尝试过向供应商添加正斜杠,但仍然无法使用。 Folder structure:
资料夹结构:
05/09/2018 13:22 .
05/09/2018 13:22 ..
03/09/2018 08:27 fonts
03/09/2018 08:27 img
05/09/2018 13:22 javascripts
03/09/2018 16:40 lib
05/09/2018 09:49 stylesheets
05/09/2018 09:45 vendors
05/09/2018 09:46 bower_components
05/09/2018 09:46 jquery-toast-plugin
05/09/2018 09:46 dist
06/09/2016 14:49 jquery.toast.min.css
06/09/2016 14:49 jquery.toast.min.js
Any help is greatly appreciated! 任何帮助是极大的赞赏!
Is vendors or bower_components directory tracked by git? git是否跟踪vendor或bower_components目录? If not is any build scripts run by heroku during the deployment?
在部署期间,heroku是否运行任何构建脚本? This scripts containes the bower install command?
该脚本包含bower install命令吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.