admin管理员组文章数量:1335555
I have a jade page, and the first thing I do is set a variable which determines the base directory used by all links.
if ! base
base = '/klog/'
// base = '/website-clear/klog/'
This is actually for a github page, so every time I render the page to html, I have to remember to change the base, and then change it back again for local editing.
There must be a better way of doing it. Currently I am thinking to have an untracked file in the local copy, that includes the base - but is that really necessary?
What is the best way to handle this issue?
I have a jade page, and the first thing I do is set a variable which determines the base directory used by all links.
if ! base
base = '/klog/'
// base = '/website-clear/klog/'
This is actually for a github page, so every time I render the page to html, I have to remember to change the base, and then change it back again for local editing.
There must be a better way of doing it. Currently I am thinking to have an untracked file in the local copy, that includes the base - but is that really necessary?
What is the best way to handle this issue?
Share Improve this question edited Sep 16, 2012 at 22:08 Billy Moon asked Sep 16, 2012 at 20:45 Billy MoonBilly Moon 58.6k27 gold badges148 silver badges244 bronze badges1 Answer
Reset to default 10A more robust solution would be checking for environment variables.
Have NODE_ENV=production
set on the production server, and do not set it on the dev server.
Then in your jade template, render different paths if the environment variable exists.
if 'production' == process.env.NODE_ENV
- base = '/website-clear/klog/'
or
- base = ( 'production' == process.env.NODE_ENV ? '/website-clear/klog/' : '/klog' );
本文标签: javascriptJadeset base directory depending on environmentStack Overflow
版权声明:本文标题:javascript - Jade - set base directory depending on environment - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742395151a2466771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论