5

I'm using browsersync via lite-server, and have the following configuration:

{
    "port": 8000,
    "files": [
        "./src/**/*.{html,htm,css,js}"
    ],
    "server": {
        "baseDir": "./src",
        "routes": {
            "node_modules": "../node_modules" <--- Attempt to serve node_modules
        }
    }
}

Project layout is like this:

node_modules src |-app |-index.html |-systemjs.config.js package.json bs-config.json

The problem is that inside index.html any reference like <script src="node_modules/....js"> fails with a 404.

How can I serve paths outside of .src directory?

Cristian E.
  • 3,116
  • 7
  • 31
  • 61

2 Answers2

5

You can expose whole project folder by adding one more element to baseDir as Edvin mentioned.

But it would be better if you will expose only /node_modules using routes:

module.exports = {
    server : {
        baseDir : './dist',
        routes : {
            '/vendor' : './node_modules'
        }
    }
}
Dmitry Lukichev
  • 2,519
  • 1
  • 16
  • 12
1

You can use multiple directory in baseDir config:

{
    "server": {
        "baseDir": ["./", "./src" ]
    }
}
Gynteniuxas
  • 7,035
  • 18
  • 38
  • 54
Rafal Sujak
  • 21
  • 1
  • 1