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.
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'
}
}
}
You can use multiple directory in baseDir config:
{
"server": {
"baseDir": ["./", "./src" ]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With