Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basedir doesn't like relative paths up the tree? #125

Closed
kevinSuttle opened this issue Apr 7, 2014 · 5 comments
Closed

basedir doesn't like relative paths up the tree? #125

kevinSuttle opened this issue Apr 7, 2014 · 5 comments

Comments

@kevinSuttle
Copy link

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. :)

@shakyShane
Copy link
Contributor

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

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

@shakyShane
Copy link
Contributor

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"
        }
    }
});

@kevinSuttle
Copy link
Author

👍 Thanks for following up, Shane. Clever solution.

@palbcn
Copy link

palbcn commented Jun 6, 2016

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

@RichardsonWTR
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants