grunt-connect:提供添加了基本URL的文件 [英] grunt-connect: serve files with base url added
问题描述
我正在使用grunt开发基于jekyll的网站作为我的任务管理器。由于其LiveReload功能,我使用grunt-contrib-connect在本地为我的文件提供文件以供开发。这些文件可以在浏览器中访问:
http:// localhost:8081 / index.html
在我的服务器上,我的文件位于子目录内,因此所有网址都有一个基本网址:
http: //path.to.server/mysite/index.html
我找不出一种方法来模拟基本网址在我的本地开发设置与grunt连接。没有这一点,我不知道如何引用我的CSS或JS文件,而无需在服务器或我的开发盒上的URL无效。
我知道jekyll的serve函数可以添加一个基本url,但它并不能提供livereload功能。
任何提示?
https://github.com/dannygarcia/grunt-jekyll =nofollow> Grunt Jekyll 运行Jekyll build命令,它有一个 raw
选项,可让您将事物追加到 _config.yml
中。通过这种方式,您可以有效地移除本地开发中的 {{site.baseurl}}
jekyll:{
development:{
options:{
config:'_config.yml',
raw:'baseurl:'
}
$,
生产:{
选项:{
config:'_config.yml'
}
}
},
I am developing jekyll-based site using grunt as my task manager. I am using grunt-contrib-connect to serve my files locally for development because of its livereload functionality. Those files are accessible in the browser at:
http://localhost:8081/index.html
On my server, my files are located within a sub-directory, so have a base url prepended to all urls:
http://path.to.server/mysite/index.html
I cannot figure out a way to simulate the base url on my local dev setup with grunt-connect. Without that, I don't know how to reference my css or js files without the urls being invalid on either the server or my dev box.
I know that jekyll's serve function can add a base url, but it does not give me the livereload functionality.
Any tips?
If you use Grunt Jekyll to run the Jekyll build commands it has a raw
option that lets you append things to your _config.yml
. That way you can effectively remove {{ site.baseurl }}
for local development
jekyll: {
development: {
options: {
config: '_config.yml',
raw: 'baseurl: '
}
},
production: {
options: {
config: '_config.yml'
}
}
},
这篇关于grunt-connect:提供添加了基本URL的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!