BrowserSync / browser-sync

Keep multiple browsers & devices in sync when building websites. https://browsersync.io
https://discord.gg/2d2xUThp
Apache License 2.0
12.19k stars 757 forks source link

what is the baseDir file path relative to? #1711

Open jinnn0 opened 5 years ago

jinnn0 commented 5 years ago

running browser sync with gulp and I am wondering when specifying basDir, is the file path relative to where the gulpfile.js is which has the browser sync setup ? when I wrote ' ./ ' I got can not get and when I wrote ' ./app ' (folder that has index.html) it shows the web page but the PROBLEM is that It doesn't seem to know where my library is and I get and error saying

" its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. " for the stylesheet

"404 not found" for javascript

i tried moving folders around it it looks like when my node_module (where i am getting libs from) is in the same directory as index.html it works but I am trying to find a way to keep this structure and get it work but no luck so far

another issue I found was that i kind of got around by doing this but as soon as I delete directory : true I get the same error again.

server: {
      baseDir: "./",
      directory: true
  }

any idea what is happening here?

current folder structure looks like -----_root --------client ------------app ---------------index.html ---------------src ------------------styles ------------------scripts ------------gulpfile.js ------------node_modules ------------package.json --------server

johndeighan commented 1 year ago

Issue opened in 2019 - still not fixed - WTF???

I'm going through a tutorial on udemy (Gulp 4: Automate your development workflow) and the presenter had to move the index.html file out of the src/ folder and into the project root. This seemed very weird to me. But when I use browsersync and set the baseDir to "./src", sure enough, just like the guy above, my CSS files are being served with MIME type "text/html" instead of the correct "text/css". I tried setting the Content-Type to "text/css" in middleware if the URL ends in ".css", but no luck. Then, I tried setting the default MIME type for CSS files in a "ready" callback, but I found that it was already set to "text/css", though as I said, CSS files are being served with Content-Type: text/html. Honestly, I'm about ready to junk browsersync!

FYI, I also tried setting "directory: true" as the person above did (and claimed that it fixed the problem), but unfortunately, it didn't change anything for me.

bye-csavier commented 2 weeks ago

@shakyShane could this be specified? Because I'm also unsure where baseDir is relative to, and the site documentation doesn't cover this.