gulp-webserver: Cannot GET html & gulp.src location ignored.
This is my gulp webserver task:
gulp = require "gulp"
$ = do require "gulp-load-plugins"
gulp.task "webserver", ->
gulp.src "dist"
.pipe $.webserver(
directoryListing : true
host : "0.0.0.0"
port : 9000
)
When i open up http://127.0.0.1:9000/
it ignores the the gulp.src location i’ve set and uses the root of the folder. But i can see files being listed:
If i click into a index.html
for example inside the dist
folder. i get this message on the page.
Cannot GET /dist/index.html
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 25 (1 by maintainers)
Using
gulp.src('./')
solved my problem about getting files content.Removed directoryListing completely and it now opens index.html automatically.
I fixed this issue with the following gulp task.
#5 solve this problem. Using this setting:
related to #14. Just removing the directoryListing option fix the root for me.
As @cedriceberhardt mentioned, using
gulp.src('./')
works. Apparently, this points to root rather thangulp.src('root')
now this working for me except one problem - index.html doesn’t open automaticly
Note to consider… when you set
directoryListing: true
renders only the root directory, regardless of the src path you specify ingulp.src('whateverPathYouChoose')
so I had to specify an object to make it work properly and render my static files correctly.something like this:
You may want to include that in the readme, and provide a better explanation.
I ran into this issue working on my second or third gulp project on my machine. The last two projects I’ve started exhibit this issue, while the very first one still works. I’ve even tried copy pasting in the code and I still get the issue of the 404 and the src being the root of my projects. Changing ports doesn’t make it work.
However, as @hinok mentioned, just running the webserver task standalone does work
We have exactly the same problem! It’s weird cause when I run only one task:
The server works, but with multiple tasks is broken. 0.5.0 works like a charm.