Browser-sync: How to correctly set routes

Created on 16 Feb 2015  路  2Comments  路  Source: BrowserSync/browser-sync

Hey people, I'm trying to setup browsersync and gulp for a few hours now and I'm stuck in making a route for my bower components folder.

Here's my file tree

https://dl.dropboxusercontent.com/u/4993216/filetree.png

And this is my current broswer-sync task.

gulp.task('browser-sync', function() {
    browserSync({
        server: {
            baseDir: ['src', '.tmp'],
            routes: {
                'bower_components': '../bower_components'
            }
        },
        open: false,
        notify: false
    });
});

Is there anything wrong with it?

My index.html inside src has an import like this <script src="bower_components/angular/angular.js"></script> and it doesn't work. :(

Most helpful comment

server: {
    baseDir: ['src', '.tmp'],
    routes:  {
        '/bower_components': 'bower_components'
    }
}

The key is the url to match, so anything that begins /bower_components

The value is which folder to serve, but it's relative to your gulpfile.js, that's why simply bower_components will work :)

All 2 comments

server: {
    baseDir: ['src', '.tmp'],
    routes:  {
        '/bower_components': 'bower_components'
    }
}

The key is the url to match, so anything that begins /bower_components

The value is which folder to serve, but it's relative to your gulpfile.js, that's why simply bower_components will work :)

Oh, thanks! It is working now :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hgl picture hgl  路  3Comments

zewa666 picture zewa666  路  3Comments

jitendravyas picture jitendravyas  路  4Comments

sedubois picture sedubois  路  3Comments

demisx picture demisx  路  4Comments