How to use (Grunt) BrowserSync to serve files 1 level deeper than the root server and maintain links?

My projects are structured like this:

/root src files |_ /public |_ /html |_ index.html |_ about.html |_ contact.html |_ /css |_ /js |_ index.php

Where all the src files: html templates, Sass and raw JS scripts are in the root and published in their respective folders publicly.

I first "create" everything in plain HTML to test functionality and flow, with links in html files just equal, relative filenames (eg <a href="about.html">

). I have set up my server to serve from / public directory and without BrowserSync to go to localhost / builds / for testing.

However, when using BrowserSync, setting --server

to public

and --index

from builds/index.html

loads the index to localhost: 3000, but in fact all files should be accessible via localhost: 3000 / builds.

This means none of the links in the html files are working because they all just point to localhost: 3000, so 404. I can't install BrowserSync to serve from / html because the CSS and JS paths are wrong.

Is there a way to get around this without moving the html files to the / public root?

+3
node.js indexing gruntjs


source to share


No one has answered this question yet

Check out similar questions:

eleven
How to copy compiled jade files to destination folder using grunt
2
BrowserSync won't load
1
Serving static files with elastic bean stitch doesn't work
1
setting angular 6 base_url not pointing to root in NodeJS server
0
How can I serve external css / js files in html files rendered by NodeJS app?
0
Express: Pointer Route not called when index.html is served statically
0
Send multiple static files with Express Router
0
Loading views with css and js with Angular and Node Routing
0
How to use the same src file after running grunt
0
Serve root static file with nginx as reverse proxy



All Articles
Loading...
X
Show
Funny
Dev
Pics