简体   繁体   English

Gulp root显示空白页面

[英]Gulp root shows blank page

I had angular JS web framework website, the source codes use gulp to run the server. 我有角度的JS web框架网站,源代码使用gulp来运行服务器。 The app folder is what I want to run. app文件夹是我想要运行的。 Every time I visit the website, I need to type "/app" at the end of my URL. 每次访问网站时,我都需要在网址末尾输入“/ app”。

https://www.myweb.com/app https://www.myweb.com/app

I had used root attribute on connect.server function in Gulp. 我在Gulp的connect.server函数中使用了root属性。 www.myweb.com/app no longer works for me and www.myweb.com shows blank page without error. www.myweb.com/app不再适合我,www.myweb.com显示空白页面没有错误。

gulp.task('localhost', function() {
  connect.server({
      root: '/app',
      port: 4567,
      livereload: true
  });
});

gulp.task('watch', function () {
    gulp.watch(['./app/*.html'], ['html']);
});

gulp.task('default', ['localhost', 'watch']);

There are several problems. 有几个问题。 First, the root path has to do with your file system, it's the directory your app is being served out of, not your URL. 首先,根路径与您的文件系统有关,它是您的应用程序的服务目录,而不是您的URL。 Second, having / at the beginning of your path makes it absolute, so it's trying to serve from a folder that doesn't exist at your system's root. 其次,在路径的开头/处使它成为绝对路径,因此它尝试从系统根目录下不存在的文件夹进行服务。

To make it serve such that your app directory is part of the path, change your root to . 要使其服务使您的app目录成为路径的一部分,请将根目录更改为. to make the current directory the gulp task starts in act as the root. 使gulp任务从当前目录开始充当root。

you can point the root of your application to the web server simply by specifying the directory name as a string. 只需将目录名称指定为字符串,即可将应用程序的根目录指向Web服务器。 The web server is not able to find the location specified because of the / , so you could try passing just root: 'app' . 由于/ ,Web服务器无法找到指定的位置,因此您可以尝试仅传递root: 'app'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM