Skip to content

Instantly share code, notes, and snippets.

@joemaller
Last active January 5, 2017 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemaller/0254b34b88cfc6a9a665025c722891b5 to your computer and use it in GitHub Desktop.
Save joemaller/0254b34b88cfc6a9a665025c722891b5 to your computer and use it in GitHub Desktop.
Example gulpfile showing how to serve Browsersync from an arbitrary subpath. Download the zip, `npm install` and `gulp watch`
var gulp = require('gulp');
var browsersync = require('browser-sync').create();
gulp.task('watch', function() {
browsersync.init({
files: './*.html',
startPath: '/some/multi/level/path',
server: {
baseDir: '-',
routes: {
'/some/multi/level/path': '.'
}
}
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example gulpfile</title>
</head>
<body>
<a href="http://stackoverflow.com/questions/30370753/gulp-browsersync-serve-at-path">Gulp + BrowserSync, serve at path</a><br>
<a href="https://github.com/BrowserSync/browser-sync/issues/1224">Is there a way to mount the application in a sub path? #1224</a>
</body>
</html>
{
"name": "so-test",
"version": "0.0.0",
"private": true,
"author": "Joe Maller <joe@joemaller.com> (https://github.com/joemaller)",
"license": "ISC",
"devDependencies": {
"browser-sync": "^2.18.5",
"gulp": "^3.9.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment