Browser-sync: basedir doesn't like relative paths up the tree?

Created on 7 Apr 2014  路  5Comments  路  Source: BrowserSync/browser-sync

For example, when I use ./app as my baseDir:

gulp.task('browser-sync', function() {
    browserSync.init(["app/*.css", "app/js/*.js"], {
        server: {
            baseDir: "./app"
        },
    });
});

I can't reference directories up the tree, resulting in a 404. Is there a workaround?
<script src="../bower_components/angular-route/angular-route.min.js"></script>

I mean, I get that it's not a natural server behavior to up the tree, so maybe I should just move the bower_components into the /app directory and shut up. :)

Most helpful comment

I know this post is old, but I made it with this configuration:

gulp.task('browserSync',function(){
    browserSync.init({
        startPath:'./app',
        server:{
            baseDir: './'
        }
    })
});

baseDir has my node_modules folder and app folder has my index.html file.

In my index.html file the script tag looks like this:
<script src='../node_modules/<path_to_file>'></script>

All 5 comments

I wouldn't tell you to shut up! :p

But yeah, the server baseDir should be the highest point of your tree. :)

For anyone that lands on this thread - you can now do this by using the routes option on the server.

browserSync({
    server: {
        baseDir: "./app",
        routes: {
             "bower_components": "./bower_components"
        }
    }
});

:+1: Thanks for following up, Shane. Clever solution.

I can't get routes to accept an absolute path, is there something I am missing?

I know this post is old, but I made it with this configuration:

gulp.task('browserSync',function(){
    browserSync.init({
        startPath:'./app',
        server:{
            baseDir: './'
        }
    })
});

baseDir has my node_modules folder and app folder has my index.html file.

In my index.html file the script tag looks like this:
<script src='../node_modules/<path_to_file>'></script>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

demisx picture demisx  路  4Comments

sedubois picture sedubois  路  3Comments

Hurtak picture Hurtak  路  3Comments

adjavaherian picture adjavaherian  路  4Comments

Zver64 picture Zver64  路  3Comments