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

Make BrowserSync use the real https URL
Can we use browser sync on external url
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?

Categories

HOME
paraview
pagination
pda
powerpoint
pascal
fftw
gradient
owl-carousel
ms-access-2016
edge
yandex
parameters
project
jquery-ui-sortable
commonjs
pega
java.util.logging
jsonpath
http-post
event-sourcing
powershell-v5.0
template-engine
connector
undertow
named-entity-recognition
r-mice
epsilon
dynamically-generated
moses
handler
subclass
panoramas
zend-debugger
turfjs
quickfixj
spring-security4
reverse
slacktextviewcontroller
protege4
sim-toolkit
subclipse
drupal-theming
signal-strength
gitlist
corruption
scalding
yii2-user
opengl-4
headless
otp
quicktime
grails-plugin
expectations
http-status-code-401
freepbx
cda
design-principles
concept-insights
toran-proxy
gocql
file-move
ons-api
poppler
text-search
sapscript
zscript
xmltype
mmwormhole
theos
cocos3d
lnk
authlogic
ebay-lms
cnf
font-awesome-4.0.0
onload-event
server-administration
mysql-error-2013
apache-abdera
argouml
xcode3.2
matlab-load
filemerge
listactivity
msr
qglwidget
globals
tabpanel
pagemethods
sun
xslcompiledtransform

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