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. :)
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>
Most helpful comment
I know this post is old, but I made it with this configuration:
baseDirhas mynode_modulesfolder andappfolder has myindex.htmlfile.In my
index.htmlfile thescripttag looks like this:<script src='../node_modules/<path_to_file>'></script>