browser-sync


Browser-sync - serve “node_modules” out of “src” directory


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?
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" ]
}
}

Related Links

How to replace .html with forward slash in BrowserSync?
Error during instillation of browser sync
When using browser-sync,why is the browser saying cannot get, while everything seems fine
How to sync the actions performed on webpage using Browsersync?
lite-server, BrowserSync: setting other URL path than /
Gulp and Browsersync injecting CSS but causing a full reload
Browser-sync - serve “node_modules” out of “src” directory
[browser-sync]browser-sync proxy can't connect to Rails Application
Browserstack not serving index.html by default
whatever i do i can't access the external URL for the site or UI
How do I kill browserSync before creating it?
Unable to install browser-sync on windows 7
browser-sync proxy fails to connect
What's the equivalent bs-config.js (Browsersync) of this command?
How to quit the browser-sync server, or how to know the running server pid
browsersync not working (note: not using gulp)

Categories

HOME
google-app-engine
grok
adal
deep-learning
cheerio
dns
android-studio-2.2
google-spreadsheet
jelastic
big-o
pyqt4
ado.net
azure-container-service
jtextpane
lanczos
bing-maps
rcloud
project
pega
android-securityexception
stellar.js
nancy
zerobrane
selectize.js
qsqlquery
symfony-2.8
feathersjs
symbols
object-storage
scriptella
ckfinder
dapper-extensions
windows-server-2003
maze
mql
python-2.6
database-comparison
github3.py
twos-complement
android-maps-extensions
instantiation
dynamic-jasper
hunspell
fossil
playframework-2.1
amazon-ses
projects-and-solutions
microsoft-metro
flask-restful
openresty
openal
opennms
tinymce-3
tf
openblas
scalding
custom-font
spring-data-couchbase
pdf-conversion
mach-o
objectscript
mapxtreme
autosar
custom-lists
vulcanize
windows-azure-queues
nikeplus-api
scaffolding
gogs
nservicebus5
riot
findfirst
false-sharing
kendo-upload
piracy-prevention
toast
iokit
microsoft-reporting
evolus-pencil
botan
typeconverter
angular-gettext
post-commit-hook
spy++
punycode
rickshaw
rmysql
jqmodal
mintty
wxformbuilder
buffering
maven-scm
getopt
accesscontrolexception
kogrid
ui-select2
facebook-timeline
pclzip
composite-component
onload-event
asplinkbutton
device-width
vfs
cakephp-1.2
saleslogix
garbage
jquery-address
entitydatasource
timthumb
quotation-marks
undefined-index
resharper-6.0
instantiationexception
qtabbar
xpsdocument
fail-fast-fail-early
localizable.strings
java1.4
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App